@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle extras = getIntent().getExtras();
    String itemName = null;
    if (extras != null && extras.containsKey(EXTRA_MENUITEM_NAME)) {
      itemName = extras.getString(EXTRA_MENUITEM_NAME);
    } else if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_MENUITEM_NAME)) {
      itemName = extras.getString(EXTRA_MENUITEM_NAME);
    }

    // Ugly way to find the item
    DineOnUser dou = DineOnUserApplication.getDineOnUser();
    DiningSession session = dou.getDiningSession();
    if (session != null) {
      for (Menu menu : session.getRestaurantInfo().getMenuList()) {
        for (MenuItem item : menu.getItems()) {
          if (item.getTitle().equals(itemName)) {
            mItem = item;
          }
        }
      }
    }

    if (mItem == null) {
      Log.e(TAG, "Unable to load menu item to show details");
      return;
    }

    setContentView(R.layout.activity_menuitem_detail);
  }
        @Override
        public void handleMessage(Message message) {
          Bundle bundle = message.getData();

          if (bundle.containsKey("showProgressDialog")) {
            myProgressDialog =
                ProgressDialog.show(ScriptActivity.this, "Installing", "Loading", true);
          } else if (bundle.containsKey("setMessageProgressDialog")) {
            if (myProgressDialog.isShowing()) {
              myProgressDialog.setMessage(bundle.getString("setMessageProgressDialog"));
            }
          } else if (bundle.containsKey("dismissProgressDialog")) {
            if (myProgressDialog.isShowing()) {
              myProgressDialog.dismiss();
            }
          } else if (bundle.containsKey("installSucceed")) {
            Toast toast =
                Toast.makeText(getApplicationContext(), "Install Succeed", Toast.LENGTH_LONG);
            toast.show();
          } else if (bundle.containsKey("installFailed")) {
            Toast toast =
                Toast.makeText(
                    getApplicationContext(),
                    "Install Failed. Please check logs.",
                    Toast.LENGTH_LONG);
            toast.show();
          }
        }
Exemplo n.º 3
0
  private void handleArgs(@Nullable Bundle args) {
    if (args == null) {
      mMultiView.setViewState(MultiStateView.VIEW_STATE_EMPTY);
      return;
    }

    List<Upload> uploads = null;

    if (args.containsKey(KEY_PASSED_FILE)) {
      LogUtil.v(TAG, "Received file from bundle");
      uploads = new ArrayList<>(1);
      uploads.add(new Upload(args.getString(KEY_PASSED_FILE)));
    } else if (args.containsKey(KEY_PASSED_LINK)) {
      mMultiView.setViewState(MultiStateView.VIEW_STATE_EMPTY);
      String link = args.getString(KEY_PASSED_LINK);
      getChildFragmentManager()
          .beginTransaction()
          .add(UploadLinkDialogFragment.newInstance(link), UploadLinkDialogFragment.TAG)
          .commit();
    } else if (args.containsKey(KEY_PASSED_URIS)) {
      ArrayList<Uri> photoUris = args.getParcelableArrayList(KEY_PASSED_URIS);

      if (photoUris != null && !photoUris.isEmpty()) {
        LogUtil.v(TAG, "Received " + photoUris.size() + " images via Share intent");
        new DecodeImagesTask(this).execute(photoUris);
        mMultiView.setViewState(MultiStateView.VIEW_STATE_LOADING);
      }
    }

    if (uploads != null && !uploads.isEmpty()) {
      mAdapter = new UploadPhotoAdapter(getActivity(), uploads, this);
      mRecyclerView.setAdapter(mAdapter);
      mMultiView.setViewState(MultiStateView.VIEW_STATE_CONTENT);
    }
  }
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   super.onCreateView(inflater, container, savedInstanceState);
   RelativeLayout root =
       (RelativeLayout) inflater.inflate(R.layout.fragment_networks_list, container, false);
   listview = (ListView) root.findViewById(R.id.networks_list);
   wifiListAdapter = new WifiListAdapter(getActivity());
   listview.setAdapter(wifiListAdapter);
   noNetworksMessage = root.findViewById(R.id.message_group);
   if (savedInstanceState != null) {
     if (savedInstanceState.containsKey(NETWORKS_FOUND)) {
       Parcelable[] storedNetworksFound = savedInstanceState.getParcelableArray(NETWORKS_FOUND);
       networksFound = new WiFiNetwork[storedNetworksFound.length];
       for (int i = 0; i < storedNetworksFound.length; ++i)
         networksFound[i] = (WiFiNetwork) storedNetworksFound[i];
       onScanFinished(networksFound);
     }
     if (savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) {
       setActivatedPosition(savedInstanceState.getInt(STATE_ACTIVATED_POSITION));
     }
   }
   registerForContextMenu(listview);
   listview.setOnItemClickListener(this);
   return root;
 }
Exemplo n.º 5
0
  private void processIntent(Intent intent) {
    // get either session instance or create one from a bookmark
    Bundle bundle = intent.getExtras();
    if (bundle.containsKey(PARAM_INSTANCE)) {
      int inst = bundle.getInt(PARAM_INSTANCE);
      session = GlobalApp.getSession(inst);
      bitmap = session.getSurface().getBitmap();
      bindSession();
    } else if (bundle.containsKey(PARAM_CONNECTION_REFERENCE)) {
      BookmarkBase bookmark = null;
      String refStr = bundle.getString(PARAM_CONNECTION_REFERENCE);
      if (ConnectionReference.isHostnameReference(refStr)) {
        bookmark = new ManualBookmark();
        bookmark.<ManualBookmark>get().setHostname(ConnectionReference.getHostname(refStr));
      } else if (ConnectionReference.isBookmarkReference(refStr)) {
        if (ConnectionReference.isManualBookmarkReference(refStr))
          bookmark =
              GlobalApp.getManualBookmarkGateway()
                  .findById(ConnectionReference.getManualBookmarkId(refStr));
        else assert false;
      }

      if (bookmark != null) connect(bookmark);
      else closeSessionActivity(RESULT_CANCELED);
    } else {
      // no session found - exit
      closeSessionActivity(RESULT_CANCELED);
    }
  }
 private void init() {
   bundle = getIntent().getExtras();
   if (bundle != null) {
     if (bundle.containsKey("fragmentName")) {
       fragmentName = bundle.getString("fragmentName");
     }
     if (bundle.containsKey("title")) {
       title = bundle.getString("title");
     }
     if (bundle.containsKey("parameters")) {
       parameters = bundle.getBundle("parameters");
     }
   }
   if (fragmentName.length() > 0) {
     try {
       fragment = (Fragment) Class.forName(fragmentName).newInstance();
       if (parameters != null) {
         fragment.setArguments(parameters);
       }
     } catch (InstantiationException e) {
       e.printStackTrace();
     } catch (IllegalAccessException e) {
       e.printStackTrace();
     } catch (ClassNotFoundException e) {
       e.printStackTrace();
     }
   }
 }
Exemplo n.º 7
0
  /**
   * Handle result from applying when clicked on notification
   * http://stackoverflow.com/questions/1198558
   * /how-to-send-parameters-from-a-notification-click-to-an-activity BaseActivity launchMode is set
   * to SingleTop for this in AndroidManifest
   */
  @Override
  protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    Log.d(Constants.TAG, "onNewIntent");

    // if a notification is clicked after applying was done, the following is processed
    Bundle extras = intent.getExtras();
    if (extras != null) {
      if (extras.containsKey(EXTRA_APPLYING_RESULT)) {
        int result = extras.getInt(EXTRA_APPLYING_RESULT);
        Log.d(Constants.TAG, "Result from intent extras: " + result);

        // download failed because of url
        String numberOfSuccessfulDownloads = null;
        if (extras.containsKey(EXTRA_NUMBER_OF_SUCCESSFUL_DOWNLOADS)) {
          numberOfSuccessfulDownloads = extras.getString(EXTRA_NUMBER_OF_SUCCESSFUL_DOWNLOADS);
          Log.d(
              Constants.TAG,
              "Applying information from intent extras: " + numberOfSuccessfulDownloads);
        }

        ResultHelper.showDialogBasedOnResult(mActivity, result, numberOfSuccessfulDownloads);
      }
    }
  }
 public AccessPoint(Context context, Bundle savedState) {
   mContext = context;
   mConfig = savedState.getParcelable(KEY_CONFIG);
   if (mConfig != null) {
     loadConfig(mConfig);
   }
   if (savedState.containsKey(KEY_SSID)) {
     ssid = savedState.getString(KEY_SSID);
   }
   if (savedState.containsKey(KEY_SECURITY)) {
     security = savedState.getInt(KEY_SECURITY);
   }
   if (savedState.containsKey(KEY_PSKTYPE)) {
     pskType = savedState.getInt(KEY_PSKTYPE);
   }
   mInfo = (WifiInfo) savedState.getParcelable(KEY_WIFIINFO);
   if (savedState.containsKey(KEY_NETWORKINFO)) {
     mNetworkInfo = savedState.getParcelable(KEY_NETWORKINFO);
   }
   if (savedState.containsKey(KEY_SCANRESULTCACHE)) {
     ArrayList<ScanResult> scanResultArrayList =
         savedState.getParcelableArrayList(KEY_SCANRESULTCACHE);
     mScanResultCache.evictAll();
     for (ScanResult result : scanResultArrayList) {
       mScanResultCache.put(result.BSSID, result);
     }
   }
   update(mConfig, mInfo, mNetworkInfo);
   mRssi = getRssi();
   mSeen = getSeen();
 }
Exemplo n.º 9
0
  private static String getTokenFromFuture(Context c, AccountManagerFuture<Bundle> future)
      throws GoogleTasksException {
    Bundle result;
    try {
      result = future.getResult();
      if (result == null) {
        throw new NullPointerException("Future result was null."); // $NON-NLS-1$
      }
    } catch (Exception e) {
      throw new GoogleTasksException(e.getLocalizedMessage(), "future-error");
    }

    // check what kind of result was returned
    String token;
    if (result.containsKey(AccountManager.KEY_AUTHTOKEN)) {
      token = result.getString(AccountManager.KEY_AUTHTOKEN);
    } else if (result.containsKey(AccountManager.KEY_INTENT)) {
      Intent intent = (Intent) result.get(AccountManager.KEY_INTENT);
      if (c instanceof Activity) {
        c.startActivity(intent);
      } else {
        throw new GoogleTasksException(
            c.getString(R.string.gtasks_error_background_sync_auth), "background-auth-error");
      }
      return TOKEN_INTENT_RECEIVED;
    } else {
      throw new GoogleTasksException(
          c.getString(R.string.gtasks_error_accountManager), "account-manager-error");
    }
    return token;
  }
 /**
  * Returns an object representation of the value for the key
  *
  * @param key one of the keys supported in {@link #putObject(int, Object)}
  * @param defaultValue the value returned if the key is not present
  * @return the object for the key, as a {@link Long}, {@link Bitmap}, {@link String}, or {@link
  *     Rating} depending on the key value, or the supplied default value if the key is not present
  * @throws IllegalArgumentException
  */
 public synchronized Object getObject(int key, Object defaultValue)
     throws IllegalArgumentException {
   switch (METADATA_KEYS_TYPE.get(key, METADATA_TYPE_INVALID)) {
     case METADATA_TYPE_LONG:
       if (mEditorMetadata.containsKey(String.valueOf(key))) {
         return mEditorMetadata.getLong(String.valueOf(key));
       } else {
         return defaultValue;
       }
     case METADATA_TYPE_STRING:
       if (mEditorMetadata.containsKey(String.valueOf(key))) {
         return mEditorMetadata.getString(String.valueOf(key));
       } else {
         return defaultValue;
       }
     case METADATA_TYPE_RATING:
       if (mEditorMetadata.containsKey(String.valueOf(key))) {
         return mEditorMetadata.getParcelable(String.valueOf(key));
       } else {
         return defaultValue;
       }
     case METADATA_TYPE_BITMAP:
       // only one key for Bitmap supported, value is not stored in mEditorMetadata Bundle
       if (key == BITMAP_KEY_ARTWORK) {
         return (mEditorArtwork != null ? mEditorArtwork : defaultValue);
       } // else: fall through to invalid key handling
     default:
       throw (new IllegalArgumentException("Invalid key " + key));
   }
 }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    final Context context = getActivity();
    mSubtypeLocaleAdapter = new SubtypeLocaleAdapter(context);
    mKeyboardLayoutSetAdapter = new KeyboardLayoutSetAdapter(context);

    final String prefSubtypes = SettingsValues.getPrefAdditionalSubtypes(mPrefs, getResources());
    setPrefSubtypes(prefSubtypes, context);

    mIsAddingNewSubtype =
        (savedInstanceState != null) && savedInstanceState.containsKey(KEY_IS_ADDING_NEW_SUBTYPE);
    if (mIsAddingNewSubtype) {
      getPreferenceScreen()
          .addPreference(SubtypePreference.newIncompleteSubtypePreference(context, mSubtypeProxy));
    }

    super.onActivityCreated(savedInstanceState);

    if (savedInstanceState != null
        && savedInstanceState.containsKey(KEY_IS_SUBTYPE_ENABLER_NOTIFICATION_DIALOG_OPEN)) {
      mSubtypePreferenceKeyForSubtypeEnabler =
          savedInstanceState.getString(KEY_SUBTYPE_FOR_SUBTYPE_ENABLER);
      final SubtypePreference subtypePref =
          (SubtypePreference) findPreference(mSubtypePreferenceKeyForSubtypeEnabler);
      mSubtypeEnablerNotificationDialog = createDialog(subtypePref);
      mSubtypeEnablerNotificationDialog.show();
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set the layout
    setContentView(R.layout.activity_directory_browser);

    // Gets the bundle data
    Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
      // Reads the title
      if (bundle.containsKey(EXTRA_TITLE)) mTitle = bundle.getString(EXTRA_TITLE);

      // Reads the start path
      if (bundle.containsKey(EXTRA_PATH)) {
        String path = bundle.getString(EXTRA_PATH);
        if (path != null) {
          mPath = new File(path);

          // Default directory
          if (!mPath.exists()) {
            mPath = Environment.getExternalStorageDirectory();
          }
        }
      }
    }

    // Setup the actionbar
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
      // Set the title
      actionBar.setTitle(mTitle);
      actionBar.setSubtitle(mPath.getAbsolutePath());
    }
  }
  /**
   * The IntentService calls this method from the default worker thread with the intent that started
   * the service. When this method returns, IntentService stops the service, as appropriate.
   */
  @Override
  protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras == null) {
      Log.e(Constants.TAG, "Extras bundle is null!");
      return;
    }

    if (!(extras.containsKey(EXTRA_ACTION))) {
      Log.e(Constants.TAG, "Extra bundle must contain an action!");
      return;
    }

    if (extras.containsKey(EXTRA_MESSENGER)) {
      mMessenger = (Messenger) extras.get(EXTRA_MESSENGER);
    }
    Bundle data = extras.getBundle(EXTRA_DATA);

    int action = extras.getInt(EXTRA_ACTION);

    setProgressCircleWithHandler(true);

    // execute action from extra bundle
    switch (action) {
      case ACTION_CHANGE_COLOR:
        int newColor = data.getInt(CHANGE_COLOR_NEW_COLOR);

        // only if enabled
        if (new AccountHelper(this).isAccountActivated()) {
          // update calendar color
          CalendarSyncAdapterService.updateCalendarColor(this, newColor);
        }

        break;

      case ACTION_CHANGE_REMINDER:
        int newMinutes = data.getInt(CHANGE_REMINDER_NEW_MINUTES);
        int reminderNo = data.getInt(CHANGE_REMINDER_NO);

        // only if enabled
        if (new AccountHelper(this).isAccountActivated()) {
          // Update all reminders to new minutes
          CalendarSyncAdapterService.updateAllReminders(this, reminderNo, newMinutes);
        }

        break;

      case ACTION_MANUAL_SYNC:

        // Force synchronous sync
        CalendarSyncAdapterService.performSync(this);

        break;

      default:
        break;
    }

    setProgressCircleWithHandler(false);
  }
  @Override
  protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);

    if (null != savedInstanceState) {
      // 地理位置
      if (savedInstanceState.containsKey("location")) {
        locationString = savedInstanceState.getString("location");
        if (null == locationString || locationString.length() < 1) {
          choiceLocationTextView.setText("告诉我你在哪里....");
        } else {
          choiceLocationTextView.setText(locationString);
        }
      }
      // 内容
      if (savedInstanceState.containsKey("content")) {
        contentEditText.setText(savedInstanceState.getString("content"));
      }
      // 图片
      if (savedInstanceState.containsKey("images")) {
        ArrayList<String> imageList = savedInstanceState.getStringArrayList("images");
        for (String string : imageList) {
          addNewsImageView(string);
        }
      }

      // 最后拍的
      if (savedInstanceState.containsKey("tmpImageName")) {
        tmpImageName = savedInstanceState.getString("tmpImageName");
      }
    }
  }
Exemplo n.º 15
0
  /** 解析Intent */
  private void parseIntent(final Intent intent) {
    final Bundle arguments = intent.getExtras();
    if (arguments != null) {
      if (arguments.containsKey(EXTRA_DIRECTORY)) {
        String directory = arguments.getString(EXTRA_DIRECTORY);
        Logger.i("onStartCommand:" + directory);
        // 扫描文件夹
        if (!mScanMap.containsKey(directory)) mScanMap.put(directory, "");
      } else if (arguments.containsKey(EXTRA_FILE_PATH)) {
        // 单文件
        String filePath = arguments.getString(EXTRA_FILE_PATH);
        Logger.i("onStartCommand:" + filePath);
        if (!StringUtils.isEmpty(filePath)) {
          if (!mScanMap.containsKey(filePath))
            mScanMap.put(filePath, arguments.getString(EXTRA_MIME_TYPE));
          //					scanFile(filePath, arguments.getString(EXTRA_MIME_TYPE));
        }
      }
    }

    if (mServiceStatus == SCAN_STATUS_NORMAL || mServiceStatus == SCAN_STATUS_END) {
      new Thread(this).start();
      // scan();
    }
  }
Exemplo n.º 16
0
  int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException {
    // Query purchases
    logDebug("Querying owned items, item type: " + itemType);
    logDebug("Package name: " + mContext.getPackageName());
    boolean verificationFailed = false;
    String continueToken = null;

    do {
      logDebug("Calling getPurchases with continuation token: " + continueToken);
      Bundle ownedItems =
          mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken);

      int response = getResponseCodeFromBundle(ownedItems);
      logDebug("Owned items response: " + String.valueOf(response));
      if (response != BILLING_RESPONSE_RESULT_OK) {
        logDebug("getPurchases() failed: " + getResponseDesc(response));
        return response;
      }
      if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST)
          || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST)
          || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) {
        logError("Bundle returned from getPurchases() doesn't contain required fields.");
        return IABHELPER_BAD_RESPONSE;
      }

      ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST);
      ArrayList<String> purchaseDataList =
          ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST);
      ArrayList<String> signatureList =
          ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST);

      for (int i = 0; i < purchaseDataList.size(); ++i) {
        String purchaseData = purchaseDataList.get(i);
        String signature = signatureList.get(i);
        String sku = ownedSkus.get(i);
        if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) {
          logDebug("Sku is owned: " + sku);
          Purchase purchase = new Purchase(itemType, purchaseData, signature);

          if (TextUtils.isEmpty(purchase.getToken())) {
            logWarn("BUG: empty/null token!");
            logDebug("Purchase data: " + purchaseData);
          }

          // Record ownership and token
          inv.addPurchase(purchase);
        } else {
          logWarn("Purchase signature verification **FAILED**. Not adding item.");
          logDebug("   Purchase data: " + purchaseData);
          logDebug("   Signature: " + signature);
          verificationFailed = true;
        }
      }

      continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN);
      logDebug("Continuation token: " + continueToken);
    } while (!TextUtils.isEmpty(continueToken));

    return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK;
  }
Exemplo n.º 17
0
 private void expandParams(Bundle params) {
   if (params == null) {
     params = new Bundle();
   }
   int id = 0;
   if (params.containsKey(RATIO)) {
     id = params.getInt(RATIO, 1);
   }
   ratio = Ratio.getRatioById(id);
   id = 0;
   if (params.containsKey(QUALITY)) {
     id = params.getInt(QUALITY, 0);
   }
   quality = Quality.getQualityById(id);
   id = 0;
   if (params.containsKey(FOCUS_MODE)) {
     id = params.getInt(FOCUS_MODE);
   }
   focusMode = FocusMode.getFocusModeById(id);
   id = 0;
   if (params.containsKey(FLASH_MODE)) {
     id = params.getInt(FLASH_MODE);
   }
   flashMode = FlashMode.getFlashModeById(id);
   id = 0;
   if (params.containsKey(HDR_MODE)) {
     id = params.getInt(HDR_MODE);
   }
   hdrMode = HDRMode.getHDRModeById(id);
 }
Exemplo n.º 18
0
 @Override
 public void onReceive(Context context, Intent intent) {
   // TODO Auto-generated method stub
   String actionstr = intent.getAction();
   if (TMNetDef.TM_REQ_RESULT_ACTION_TRAFFIC.equals(actionstr)) {
     Bundle bundle = intent.getExtras();
     if (bundle != null) {
       if (bundle.containsKey(TMNetDef.TAG_TM_REQ_ID)) {
         int id = bundle.getInt(TMNetDef.TAG_TM_REQ_ID);
         updateLogView("recv tm result id =" + id + " while current id =" + mTransId);
         if (mTransId == id) {
           if (bundle.containsKey(TMNetDef.TAG_TM_REQ_STATUS)
               && bundle.containsKey(TMNetDef.TAG_TM_REQ_DETAIL_TYPE)) {
             int status = bundle.getInt(TMNetDef.TAG_TM_REQ_STATUS);
             int detailtype = bundle.getInt(TMNetDef.TAG_TM_REQ_DETAIL_TYPE);
             if (TMNetDef.TM_REQ_TYPE_TMC_STATUS == detailtype) {
               updateLogView("recv TM_REQ_TYPE_TMC_STATUS result, status=" + status);
             } else {
               updateLogView("recv unknow tm result");
             }
           }
         }
       }
     }
   }
 }
Exemplo n.º 19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.video_activity_layout);
    Bundle budleIn = getIntent().getExtras();
    if (budleIn != null) {
      if (budleIn.containsKey("closeOnFinish")) {
        closeOnFinish = budleIn.getBoolean("closeOnFinish");
        if (closeOnFinish) persentsDownloadToStartPlay = 1000;
      }
      if (budleIn.containsKey("videoUrl")) {
        {
          this.embedUrlStr = budleIn.getString("videoUrl");
        }
      }
      if (budleIn.containsKey("streamMode")) {
        {
          this.streamMode = budleIn.getBoolean("streamMode");
          // streamMode=false;
        }
      }
    }
    // String url = getIntent().getExtras().getString("videoUrl");
    // this.embedUrlStr = "http://www.youtube.com/embed/n7hfg1Zd-_o";
    // "http://new.padcms.adyax.com//resize/thumbnail/none/element/00/00/01/52/resource.mp4";

    // "http://www.mp4point.com/downloads/55ecd9809707.mp4";
    // "http://www.youtube.com/embed/n7hfg1Zd-_o";//
    // "http://gsmnet.ru/3gp/kipelov_i_zdes.3gp";
    //
    // closeOnFinish = getIntent().getExtras().getBoolean("close");

    initializeContols();
    defineTopContols();
    defineBottomControls();

    // this.prepareCashFolder();
    showDialog(DIALOG_PREPARING);
    this.initializeCashFile();
    if (this.isOnline()) {
      this.makePreparationOfVideoSourceOnBaseURL(embedUrlStr);
    } else {
      if (!streamMode) this.playVideoInUi();
      else
        this.showErrorAlert(
            getString(R.string.error_message_title), getString(R.string.error_no_connection));
    }

    /*
     * initializeContols(); defineTopContols(); defineBottomControls();
     */

    /* startVideo(url); */

    /* playVideoInUi(); */

    // seekBarUpdaterStart();
    defineRootOnClickListener();
  }
Exemplo n.º 20
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    if (args != null) {
      if (args.containsKey(Constants.ARG_ACCOUNT_ID)) {
        String accountId = args.getString(Constants.ARG_ACCOUNT_ID);
        pocket = checkNotNull(application.getAccount(accountId));
      }

      if (args.containsKey(Constants.ARG_URI)) {
        try {
          processUri(args.getString(Constants.ARG_URI));
        } catch (CoinURIParseException e) {
          // TODO handle more elegantly
          Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show();
          ACRA.getErrorReporter().handleException(e);
        }
      }
      if (pocket == null) {
        List<WalletAccount> accounts = application.getAllAccounts();
        if (accounts.size() > 0) pocket = accounts.get(0);
        if (pocket == null) {
          ACRA.getErrorReporter()
              .putCustomData("wallet-exists", application.getWallet() == null ? "no" : "yes");
          Toast.makeText(getActivity(), R.string.no_such_pocket_error, Toast.LENGTH_LONG).show();
          getActivity().finish();
          return;
        }
      }
      checkNotNull(pocket, "No account selected");
    } else {
      throw new RuntimeException("Must provide account ID or a payment URI");
    }

    sendAmountType = pocket.getCoinType();

    messageFactory = pocket.getCoinType().getMessagesFactory();

    if (savedInstanceState != null) {
      address = (Address) savedInstanceState.getSerializable(STATE_ADDRESS);
      addressTypeCanChange = savedInstanceState.getBoolean(STATE_ADDRESS_CAN_CHANGE_TYPE);
      sendAmount = (Value) savedInstanceState.getSerializable(STATE_AMOUNT);
      sendAmountType = (CoinType) savedInstanceState.getSerializable(STATE_AMOUNT_TYPE);
    }

    updateBalance();
    setHasOptionsMenu(true);
    mNavigationDrawerFragment =
        (NavigationDrawerFragment) getFragmentManager().findFragmentById(R.id.navigation_drawer);

    String localSymbol = config.getExchangeCurrencyCode();
    for (ExchangeRatesProvider.ExchangeRate rate : getRates(getActivity(), localSymbol)) {
      localRates.put(rate.currencyCodeId, rate.rate);
    }

    loaderManager.initLoader(ID_RATE_LOADER, null, rateLoaderCallbacks);
    loaderManager.initLoader(ID_RECEIVING_ADDRESS_LOADER, null, receivingAddressLoaderCallbacks);
  }
Exemplo n.º 21
0
  private <T, U extends RestClientRootUrl & RestClientHeaders & RestClientSupport>
      RestCallResult doFireRequestWithPersistentAuth(Request<T> request, Response<T> response) {
    RestCallResult result = RestCallResult.OTHER_ERROR;
    U restClient = request.getRestClient();

    try {
      Bundle bundle = accountPropertiesManager.getAuthToken().getResult();
      if (bundle.containsKey(AccountManager.KEY_AUTHTOKEN)) {
        String authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN);

        if (TextUtils.isEmpty(authToken)) {
          messageHelper.showError(
              ErrorType.REST_MAJOR, context.getString(R.string.rest_token_missing));
        } else {
          prepareAuthToken(restClient, version, authToken);
          T restResponse = request.fire();
          result = RestCallResult.SUCCESS;
          if (response != null) {
            response.onResponse(restResponse);
          }
        }
      } else if (bundle.containsKey(AccountManager.KEY_INTENT)) {
        Intent accountAuthenticatorResponse = bundle.getParcelable(AccountManager.KEY_INTENT);
        Intent editConnectionIntent = new Intent(Broadcasts.NO_CONNECTION_SPECIFIED);
        editConnectionIntent.putExtra(AccountManager.KEY_INTENT, accountAuthenticatorResponse);
        context.sendBroadcast(editConnectionIntent);

        result = RestCallResult.CONNECTION_ERROR;
      }
    } catch (ResourceAccessException | AuthenticatorException e) {
      messageHelper.showError(ErrorType.REST_MINOR, e);
      result = RestCallResult.CONNECTION_ERROR;
    } catch (HttpClientErrorException e) {
      String msg = e.getMessage();
      switch (e.getStatusCode()) {
        case UNAUTHORIZED:
          // ok, session id is not valid anymore - invalidate it
          accountPropertiesManager.setAuthToken(null);
          result = RestCallResult.AUTH_ERROR;
          break;
        case NOT_FOUND:
          messageHelper.showError(
              ErrorType.REST_MAJOR,
              context.getString(R.string.rest_url_missing, msg, restClient.getRootUrl()));
          break;
        default:
          messageHelper.showError(ErrorType.REST_MAJOR, messageHelper.createMessage(e));
          break;
      }
    } catch (Exception e) {
      messageHelper.showError(ErrorType.REST_MAJOR, e);
    }

    if (result == RestCallResult.SUCCESS) {
      messageHelper.resetMinorErrors();
    }

    return result;
  }
Exemplo n.º 22
0
 @Override
 public void onRestoreInstanceState(Bundle savedInstanceState) {
   super.onRestoreInstanceState(savedInstanceState);
   if (savedInstanceState.containsKey("irbOutput"))
     irbOutput.setText(savedInstanceState.getCharSequence("irbOutput"));
   irbInput.onRestoreInstanceState(savedInstanceState);
   if (savedInstanceState.containsKey("tab")) tabs.setCurrentTab(savedInstanceState.getInt("tab"));
 }
Exemplo n.º 23
0
 private void handleArguments(Bundle arguments) {
   if (arguments.containsKey(ARGUMENT_URL)) {
     mUrl = arguments.getString(ARGUMENT_URL);
     mLocal = mUrl.contains("file://");
   }
   if (arguments.containsKey(ARGUMENT_SHARE)) {
     mShare = arguments.getString(ARGUMENT_SHARE);
   }
 }
  @Override
  protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
    if (savedInstanceState.containsKey("chooser_type")) {
      chooserType = savedInstanceState.getInt("chooser_type");
    }

    if (savedInstanceState.containsKey("media_path")) {
      filePath = savedInstanceState.getString("media_path");
    }
    super.onRestoreInstanceState(savedInstanceState);
  }
 private void injectExtras_() {
   Bundle extras_ = getIntent().getExtras();
   if (extras_ != null) {
     if (extras_.containsKey(WORK_INFO_ID_EXTRA)) {
       workInfoID = extras_.getInt(WORK_INFO_ID_EXTRA);
     }
     if (extras_.containsKey(DATE_EXTRA)) {
       date = extras_.getString(DATE_EXTRA);
     }
   }
 }
Exemplo n.º 26
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    AppSettings.initialize(this, this);
    dataManager = new NewsManager(this);
    permissionHandler = new StoragePermissionHandler(this);

    if (AppSettings.firstStart()) {
      Intent intent = new Intent(this, SelectSitesActivity.class);
      intent.putExtra(AppCode.SEND_PURPOSE, SelectSitesActivity.For.APP_FIRST_START);
      startActivity(intent);
      finish();
      return;
    }

    setContentView(R.layout.a_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawer,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    assert navigationView != null : "Navigation view is null";
    navigationView.setNavigationItemSelectedListener(this);

    fragmentManager = new FragmentManager(this, navigationView, R.id.main_content);

    updateDrawer(true);

    Bundle extras = getIntent().getExtras();
    if (extras != null && extras.containsKey(AppCode.SEND_NEWS_IDS)) {
      int[] news_codes = extras.getIntArray(AppCode.SEND_NEWS_IDS);
      newsFragment = NewsListFragment.instanceForNotification(news_codes);
    } else newsFragment = NewsListFragment.instanceFor(-1);

    if (extras != null && extras.containsKey(AppCode.RESTART)) {
      ScheduledDownloadReceiver.scheduleDownloads(
          this, new ScheduleManager(this).getDownloadSchedules());
    }

    newsFragment.setRetainInstance(true);

    fragmentManager.addFragment(newsFragment, R.id.nav_my_news);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle args = getArguments();
    if (args != null && args.containsKey(REFERENCE_KEY)) {
      mReference = args.getInt(REFERENCE_KEY);
    }
    if (args != null && args.containsKey(THEME_RES_ID_KEY)) {
      mTheme = args.getInt(THEME_RES_ID_KEY);
    }
    if (args != null && args.containsKey(PLUS_MINUS_VISIBILITY_KEY)) {
      mPlusMinusVisibility = args.getInt(PLUS_MINUS_VISIBILITY_KEY);
    }
    if (args != null && args.containsKey(DECIMAL_VISIBILITY_KEY)) {
      mDecimalVisibility = args.getInt(DECIMAL_VISIBILITY_KEY);
    }
    if (args != null && args.containsKey(MIN_NUMBER_KEY)) {
      mMinNumber = (BigDecimal) args.getSerializable(MIN_NUMBER_KEY);
    }
    if (args != null && args.containsKey(MAX_NUMBER_KEY)) {
      mMaxNumber = (BigDecimal) args.getSerializable(MAX_NUMBER_KEY);
    }
    if (args != null && args.containsKey(LABEL_TEXT_KEY)) {
      mLabelText = args.getString(LABEL_TEXT_KEY);
    }
    if (args != null && args.containsKey(CURRENT_NUMBER_KEY)) {
      mCurrentNumber = args.getInt(CURRENT_NUMBER_KEY);
    }
    if (args != null && args.containsKey(CURRENT_DECIMAL_KEY)) {
      mCurrentDecimal = args.getDouble(CURRENT_DECIMAL_KEY);
    }
    if (args != null && args.containsKey(CURRENT_SIGN_KEY)) {
      mCurrentSign = args.getInt(CURRENT_SIGN_KEY);
    }

    setStyle(DialogFragment.STYLE_NO_TITLE, 0);

    // Init defaults
    mTextColor = getResources().getColorStateList(R.color.dialog_text_color_holo_dark);
    mDialogBackgroundResId = R.drawable.dialog_full_holo_dark;

    if (mTheme != -1) {
      TypedArray a =
          getActivity()
              .getApplicationContext()
              .obtainStyledAttributes(mTheme, R.styleable.BetterPickersDialogFragment);

      mTextColor = a.getColorStateList(R.styleable.BetterPickersDialogFragment_bpTextColor);
      mDialogBackgroundResId =
          a.getResourceId(
              R.styleable.BetterPickersDialogFragment_bpDialogBackground, mDialogBackgroundResId);
    }
  }
  @Override
  /** Creates the activity. */
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_artist);

    if (savedInstanceState != null
        && (savedInstanceState.containsKey("name") || savedInstanceState.containsKey("mbid"))) {
      name = savedInstanceState.getString("name");
      mbid = savedInstanceState.getString("mbid");
    } else {
      Bundle b = getIntent().getExtras();
      name = b.getString("name");
      mbid = b.getString("mbid");
    }

    actionBar.setTitle(name);

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    artistInfoFragment =
        (ArtistInfoFragment) Fragment.instantiate(this, ArtistInfoFragment.class.getName());
    artistAlbumsFragment =
        (ArtistAlbumsFragment) Fragment.instantiate(this, ArtistAlbumsFragment.class.getName());
    similarArtistsFragment =
        (SimilarArtistsFragment) Fragment.instantiate(this, SimilarArtistsFragment.class.getName());

    sectionsPagerAdapter = new SectionsPagerAdapter(this, getSupportFragmentManager());

    sectionsPagerAdapter.addFragment(artistInfoFragment);
    sectionsPagerAdapter.addFragment(artistAlbumsFragment);
    sectionsPagerAdapter.addFragment(similarArtistsFragment);

    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setOffscreenPageLimit(2);
    viewPager.setAdapter(sectionsPagerAdapter);

    viewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {

          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });

    for (int i = 0; i < sectionsPagerAdapter.getCount(); i++) {
      actionBar.addTab(
          actionBar.newTab().setText(sectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    loadArtist();
  }
Exemplo n.º 29
0
 @Override
 protected void onRestoreInstanceState(Bundle load) {
   if (load != null) {
     super.onRestoreInstanceState(load);
   }
   if (load != null && load.containsKey(TRACKURI)) {
     mTrackUri = Uri.withAppendedPath(Tracks.CONTENT_URI, load.getString(TRACKURI));
   }
   if (load != null && load.containsKey("FLIP")) {
     mViewFlipper.setDisplayedChild(load.getInt("FLIP"));
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i(tag, "onCreate: " + ((savedInstanceState == null) ? "creating" : "re-initializing"));

    // if we start this activity, the following must be true:
    // 1) Google Maps Engine is selected in preferences
    // 2) A google user is selected

    // default initializers
    mAlertMsg = getString(R.string.please_wait);
    mAlertShowing = false;

    setTitle(
        getString(R.string.app_name)
            + " > "
            + getString(R.string.send_data)); // get any simple saved
    // state...

    // resets alert message and showing dialog if the screen is rotated
    if (savedInstanceState != null) {
      if (savedInstanceState.containsKey(ALERT_MSG)) {
        mAlertMsg = savedInstanceState.getString(ALERT_MSG);
      }
      if (savedInstanceState.containsKey(ALERT_SHOWING)) {
        mAlertShowing = savedInstanceState.getBoolean(ALERT_SHOWING, false);
      }
    }

    long[] selectedInstanceIDs = null;

    Intent intent = getIntent();
    selectedInstanceIDs = intent.getLongArrayExtra(FormEntryActivity.KEY_INSTANCES);

    mInstancesToSend = new Long[(selectedInstanceIDs == null) ? 0 : selectedInstanceIDs.length];
    if (selectedInstanceIDs != null) {
      for (int i = 0; i < selectedInstanceIDs.length; ++i) {
        mInstancesToSend[i] = selectedInstanceIDs[i];
      }
    }

    // at this point,
    // we don't expect this to be empty...
    if (mInstancesToSend.length == 0) {
      Log.e(tag, "onCreate: No instances to upload!");
      // drop through --
      // everything will process through OK
    } else {
      Log.i(tag, "onCreate: Beginning upload of " + mInstancesToSend.length + " instances!");
    }

    runTask();
  }