private void loadInput() {
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();

    if (extras != null) {
      aspectX = extras.getInt(Crop.Extra.ASPECT_X);
      aspectY = extras.getInt(Crop.Extra.ASPECT_Y);
      maxX = extras.getInt(Crop.Extra.MAX_X);
      maxY = extras.getInt(Crop.Extra.MAX_Y);
      saveUri = extras.getParcelable(MediaStore.EXTRA_OUTPUT);
    }

    sourceUri = intent.getData();
    if (sourceUri != null) {
      exifRotation =
          CropUtil.getExifRotation(CropUtil.getFromMediaUri(this, getContentResolver(), sourceUri));

      InputStream is = null;
      try {
        sampleSize = calculateBitmapSampleSize(sourceUri);
        is = getContentResolver().openInputStream(sourceUri);
        BitmapFactory.Options option = new BitmapFactory.Options();
        option.inSampleSize = sampleSize;
        rotateBitmap = new RotateBitmap(BitmapFactory.decodeStream(is, null, option), exifRotation);
      } catch (IOException e) {
        Log.e("Error reading image: " + e.getMessage(), e);
        setResultException(e);
      } catch (OutOfMemoryError e) {
        Log.e("OOM reading image: " + e.getMessage(), e);
        setResultException(e);
      } finally {
        CropUtil.closeSilently(is);
      }
    }
  }
Пример #2
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);
 }
 @Override
 public void onRestoreInstanceState(Bundle savedInstanceState) {
   super.onRestoreInstanceState(savedInstanceState);
   mTrimStartTime = savedInstanceState.getInt(KEY_TRIM_START, 0);
   mTrimEndTime = savedInstanceState.getInt(KEY_TRIM_END, 0);
   mVideoPosition = savedInstanceState.getInt(KEY_VIDEO_POSITION, 0);
 }
Пример #4
0
        @Override
        public void handleMessage(Message msg) {
          Bundle data = msg.getData();

          String jobIdString = data.getString(SiteController.MESSAGE_KEY_JOB_ID);
          int jobId = (jobIdString != null) ? Integer.parseInt(jobIdString) : -1;
          Job job = (Job) (new JobTable()).get(mContext, jobId);

          int messageType = data.getInt(SiteController.MESSAGE_KEY_TYPE);
          switch (messageType) {
            case SiteController.MESSAGE_TYPE_SUCCESS:
              String result = data.getString(SiteController.MESSAGE_KEY_RESULT);
              jobSucceeded(result);
              break;
            case SiteController.MESSAGE_TYPE_FAILURE:
              int errorCode = data.getInt(SiteController.MESSAGE_KEY_CODE);
              String errorMessage = data.getString(SiteController.MESSAGE_KEY_MESSAGE);
              Exception exception =
                  (Exception) data.getSerializable(SiteController.MESSAGE_KEY_EXCEPTION);
              jobFailed(exception, errorCode, errorMessage);
              break;
            case SiteController.MESSAGE_TYPE_PROGRESS:
              String message = data.getString(SiteController.MESSAGE_KEY_MESSAGE);
              float progress = data.getFloat(SiteController.MESSAGE_KEY_PROGRESS);
              jobProgress(job, progress, message);
              break;
          }
        }
Пример #5
0
  @Override
  protected void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
      Bundle bundle = (Bundle) state;
      super.onRestoreInstanceState(bundle.getParcelable(INATANCE_STATE));
      mMaxProcess = bundle.getInt(INSTANCE_MAX_PROCESS);
      mCurProcess = bundle.getInt(INSTANCE_CUR_PROCESS);
      mReachedColor = bundle.getInt(INSTANCE_REACHED_COLOR);
      mReachedWidth = bundle.getFloat(INSTANCE_REACHED_WIDTH);
      isHasReachedCornerRound = bundle.getBoolean(INSTANCE_REACHED_CORNER_ROUND);
      mUnreachedColor = bundle.getInt(INSTANCE_UNREACHED_COLOR);
      mUnreachedWidth = bundle.getFloat(INSTANCE_UNREACHED_WIDTH);
      mPointerColor = bundle.getInt(INSTANCE_POINTER_COLOR);
      mPointerRadius = bundle.getFloat(INSTANCE_POINTER_RADIUS);
      isHasPointerShadow = bundle.getBoolean(INSTANCE_POINTER_SHADOW);
      mPointerShadowRadius = bundle.getFloat(INSTANCE_POINTER_SHADOW_RADIUS);
      isHasWheelShadow = bundle.getBoolean(INSTANCE_WHEEL_SHADOW);
      mPointerShadowRadius = bundle.getFloat(INSTANCE_WHEEL_SHADOW_RADIUS);
      isHasCache = bundle.getBoolean(INSTANCE_WHEEL_HAS_CACHE);
      isCanTouch = bundle.getBoolean(INSTANCE_WHEEL_CAN_TOUCH);
      initPaints();
    } else {
      super.onRestoreInstanceState(state);
    }

    if (mChangListener != null) {
      mChangListener.onChanged(this, mMaxProcess, mCurProcess);
    }
  }
  /**
   * Creates new instance of JapaneseCharacter from saved instance in given bundle.
   *
   * @param bundle bundle with saved JapaneseCharacter
   * @return returns new instance of JapaneseCharacter or null if bundle is null
   */
  public static JapaneseCharacter newInstanceFromBundle(Bundle bundle) {
    if (bundle == null) {
      return null;
    }
    JapaneseCharacter japaneseCharacter = new JapaneseCharacter();
    japaneseCharacter.setLiteral(bundle.getString(SAVE_CHARACTER_LITERAL));
    japaneseCharacter.setRadicalClassic(bundle.getInt(SAVE_CHARACTER_RADICAL, 0));
    japaneseCharacter.setGrade(bundle.getInt(SAVE_CHARACTER_GRADE, 0));
    japaneseCharacter.setStrokeCount(bundle.getInt(SAVE_CHARACTER_STROKE_COUNT, 0));
    japaneseCharacter.setSkip(bundle.getString(SAVE_CHARACTER_SKIP));
    japaneseCharacter.parseDicRef(bundle.getString(SAVE_CHARACTER_DIC_REF));
    japaneseCharacter.parseRmGroupJaOn(bundle.getString(SAVE_CHARACTER_JA_ON));
    japaneseCharacter.parseRmGroupJaKun(bundle.getString(SAVE_CHARACTER_JA_KUN));
    japaneseCharacter.parseMeaningEnglish(bundle.getString(SAVE_CHARACTER_ENGLISH));
    japaneseCharacter.parseMeaningFrench(bundle.getString(SAVE_CHARACTER_FRENCH));
    /*
     *  dutch, german, russian aren't in current kanjidict 2
     */
    japaneseCharacter.parseMeaningDutch(bundle.getString(SAVE_CHARACTER_DUTCH));
    japaneseCharacter.parseMeaningGerman(bundle.getString(SAVE_CHARACTER_GERMAN));
    japaneseCharacter.parseMeaningRussian(bundle.getString(SAVE_CHARACTER_RUSSIAN));
    japaneseCharacter.parseNanori(bundle.getString(SAVE_CHARACTER_NANORI));

    return japaneseCharacter.getLiteral() != null && japaneseCharacter.getLiteral().length() > 0
        ? japaneseCharacter
        : null;
  }
Пример #7
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   Bundle bundle = this.getArguments();
   i = bundle.getInt("page", 0);
   user = images.get(bundle.getInt("page", 0));
 }
  public void findViews() {
    intent = getIntent();
    params = intent.getExtras();
    IdPessoa = params.getInt("Gestor");
    servidor = new Servidor();
    servidor.setPessoaId(params.getInt("Gestor"));

    // Prazo inscrições.
    editTextInicioInscricoes = (EditText) findViewById(R.id.editTextInicioInscricoes);
    editTextInicioInscricoes.setInputType(InputType.TYPE_NULL);
    editTextFimInscricoes = (EditText) findViewById(R.id.editTextFimInscricoes);
    editTextInicioInscricoes.setInputType(InputType.TYPE_NULL);

    // Prazo relatório parcial e final
    editTextPrazoRelatorioParcial = (EditText) findViewById(R.id.editTextPrazoRelatorioParcial);
    editTextPrazoRelatorioParcial.setInputType(InputType.TYPE_NULL);
    editTextPrazoRelatorioFinal = (EditText) findViewById(R.id.editTextPrazoRelatorioFinal);
    editTextPrazoRelatorioFinal.setInputType(InputType.TYPE_NULL);

    editTextNumeroEdital = (EditText) findViewById(R.id.editTextNumeroEdital);
    editTextAno = (EditText) findViewById(R.id.editTextAno);
    editTextNumeroVagas = (EditText) findViewById(R.id.editTextNumeroVagas);
    editTextBolsaOrientador = (EditText) findViewById(R.id.editTextBolsaOrientador);
    editTextBolsaDiscente = (EditText) findViewById(R.id.editTextBolsaDiscente);
    spinnerProgramaInstitucional = (Spinner) findViewById(R.id.spinnerProgramaInstitucional);
    spinnerTipoEdital = (Spinner) findViewById(R.id.spinnerTipoEdital);
    buttonCadastrarEdital = (Button) findViewById(R.id.buttonCadastrarEdital);

    actionBar = getActionBar();
    actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.background_menu));
    builderLogout = new AlertDialog.Builder(this);
    sessionManager = new SessionManager(this);
  }
  @NonNull
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final int theme = args.getInt(THEME);
    final int value = args.getInt(VALUE);
    final int minValue = args.getInt(MIN_VALUE);
    final int maxValue = args.getInt(MAX_VALUE);

    if (theme == VALUE_NULL) {
      numberPickerDialog = new NumberPickerDialog(getActivity(), this, value, minValue, maxValue);
    } else {
      numberPickerDialog =
          new NumberPickerDialog(getActivity(), theme, this, value, minValue, maxValue);
    }
    if (iconId != VALUE_NULL) {
      setIcon(iconId);
    }
    if (title != null) {
      setTitle(title);
    }
    if (titleId != VALUE_NULL) {
      setTitle(titleId);
    }
    return numberPickerDialog;
  }
Пример #10
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   if (savedInstanceState != null) {
     mCategoryId = savedInstanceState.getInt("category_id");
     mSelectionMode = savedInstanceState.getBoolean("selection_mode");
     mIsEditing = savedInstanceState.getBoolean("edit_category");
     mCategoryIcon = savedInstanceState.getInt("category_icon");
     mCategoryName = savedInstanceState.getString("category_name");
     IconSetter dialog = (IconSetter) getFragmentManager().findFragmentByTag("set_icon");
     if (dialog != null) {
       dialog.setListener(
           new IconSetter.OnIconChosen() {
             @Override
             public void onChosen(int id) {
               mCategoryIcon = id;
               mCategoryIconView.setImageResource(Application.getThemedIcons()[mCategoryIcon]);
             }
           });
     }
   } else {
     mCategoryId = AccountManager.ALL_CATEGORY_ID;
     mSelectionMode = mIsEditing = false;
     mCategoryIcon = -1;
     mCategoryName = null;
   }
   mFabIn = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_bottom);
   mFabOut = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_out_bottom);
   mFabIn.setAnimationListener(this);
   mFabOut.setAnimationListener(this);
 }
Пример #11
0
        @Override
        public void handleMessage(Message message) {
          if (message.what == 1) {
            // 更新头像
            mAdapter.notifyDataSetChanged();
          } else if (message.what == 2) {
            // 更新图片
            HLog.out(TAG, "message.what:" + message.what);
            mAdapter.notifyDataSetChanged();
          } else if (message.what == 10) {
            // 更新评论
            Bundle bundle = message.getData();
            Comment xComment = new Comment();
            xComment.setR_id(bundle.getInt("nid"));
            xComment.setUser_id(mUser.getUid());
            xComment.setText(bundle.getString("comment"));
            xComment.setAdd_Time(Integer.parseInt(bundle.getString("time")));
            xComment.setNickname(mUser.getNickname());
            xComment.setHead_pic(bundle.getString("head_pic"));
            ArrayList<Comment> cm = data.get(bundle.getInt("position")).getBcomment();
            if (cm == null) {
              cm = new ArrayList<Comment>();
            }

            cm.add(xComment);
            data.get(bundle.getInt("position")).setBcomment(cm);
            data.get(bundle.getInt("position")).setI_comment(true);
            mAdapter.notifyDataSetChanged();
            Utils.Toast(mActivity, "温馨提示:", "评论成功!");
          } else if (message.what == 1002) {
            mAdapter.notifyDataSetChanged();
          }
        }
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   if (savedInstanceState != null
       && savedInstanceState.containsKey(KEY_HOUR_OF_DAY)
       && savedInstanceState.containsKey(KEY_MINUTE)
       && savedInstanceState.containsKey(KEY_IS_24_HOUR_VIEW)) {
     mInitialHourOfDay = savedInstanceState.getInt(KEY_HOUR_OF_DAY);
     mInitialMinute = savedInstanceState.getInt(KEY_MINUTE);
     mIs24HourMode = savedInstanceState.getBoolean(KEY_IS_24_HOUR_VIEW);
     mInKbMode = savedInstanceState.getBoolean(KEY_IN_KB_MODE);
     mStyleResId = savedInstanceState.getInt(KEY_STYLE);
     if (savedInstanceState.containsKey(KEY_FUTURE_MINUTES_LIMIT)) {
       mFutureMinutesLimit = savedInstanceState.getInt(KEY_FUTURE_MINUTES_LIMIT);
     }
     if (savedInstanceState.containsKey(KEY_PAST_MINUTES_LIMIT)) {
       mPastMinutesLimit = savedInstanceState.getInt(KEY_PAST_MINUTES_LIMIT);
     }
     if (savedInstanceState.containsKey(KEY_CURRENT_DATE)) {
       mValidateDateTime = (Calendar) savedInstanceState.getSerializable(KEY_CURRENT_DATE);
     }
     if (savedInstanceState.containsKey(KEY_PICKER_DATE)) {
       mPickerDate = (Calendar) savedInstanceState.getSerializable(KEY_PICKER_DATE);
     }
   } else {
     if (mIs24HourMode == null) {
       mIs24HourMode = DateFormat.is24HourFormat(getContext());
     }
   }
 }
Пример #13
0
  public void loadInstanceState(Bundle bundle) {

    float[] locationX = bundle.getFloatArray(LOCATIONX);
    float[] locationY = bundle.getFloatArray(LOCATIONY);
    int[] weights = bundle.getIntArray(WEIGHT);
    PlayerTurn = bundle.getInt(Turn);
    player1Score = bundle.getInt(Score1);
    player2Score = bundle.getInt(Score2);
    int Turn = bundle.getInt(First);
    blocks = new ArrayList<Block>();
    for (int i = 0; i < locationX.length - 1; i++) {
      if (Turn == 1) {
        blocks.add(new Block(red, weights[i], locationX[i], locationY[i]));
        Turn = 2;
      } else {
        Turn = 1;
        blocks.add(new Block(brown, weights[i], locationX[i], locationY[i]));
      }
    }
    yPositionTracker = locationY[locationY.length - 1];
    if (PlayerTurn == 1)
      tempBlock =
          new Block(
              red, weights[weights.length - 1], locationX[locationY.length - 1], yPositionTracker);
    else
      tempBlock =
          new Block(
              brown,
              weights[weights.length - 1],
              locationX[locationY.length - 1],
              yPositionTracker);
    view.updateScore(String.valueOf(player1Score), String.valueOf(player2Score));
  }
Пример #14
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.image_gallary, container, false);

    Bundle bundle = this.getArguments();
    url = bundle.getInt("url");
    backimageUrl = bundle.getInt("backimageUrl");

    // set images here
    gallary_image_id = (ImageView) view.findViewById(R.id.gallary_image_id);

    try {

      Picasso.with(getActivity()).load(url).fit().into(gallary_image_id);

    } catch (Exception e) {
      // TODO: handle exception
      e.printStackTrace();
    }

    // set back images here
    back_image_id = (ImageView) view.findViewById(R.id.back_image_id);

    try {

      Picasso.with(getActivity()).load(backimageUrl).fit().into(back_image_id);

    } catch (Exception e) {
      // TODO: handle exception
      e.printStackTrace();
    }

    return view;
  }
Пример #15
0
  @SuppressWarnings("unchecked")
  private void setupParams(Intent i) {
    Bundle extras = i.getExtras();
    locationAccuracy = extras.getInt(LOCATION_ACCURACY, Criteria.ACCURACY_COARSE);
    locationPower = extras.getInt(LOCATION_POWER, Criteria.POWER_MEDIUM);
    isAppend = extras.getBoolean(FIREBASE_APPEND);
    pollInterval = extras.getLong(LOCATION_POLL_INTERVAL, POLL_INTERVAL);
    String ref = extras.getString(FIREBASE_REF);
    if (ref != null) {
      firebaseRef = ref;
    } else {
      firebaseRef = URL;
    }

    // Notification stuff
    String clazz = extras.getString(NOTIFICATION_ACTIVITY);
    if (clazz != null) {
      try {
        notifiedActivity = (Class<Activity>) Class.forName(clazz);
      } catch (ClassCastException e) {
        notifiedActivity = null;
      } catch (ClassNotFoundException e) {
        notifiedActivity = null;
      }
      startupText = extras.getString(NOTIFICATION_STARTUP);
      notificationText = extras.getString(NOTIFICATION_TEXT);
    }
    int iconId = extras.getInt(NOTIFICATION_ICON, -1);
    if (iconId != -1 && notifiedActivity != null && startupText != null) {
      icon = iconId;
      if (notificationText == null) {
        notificationText = startupText;
      }
    }
  }
  @Override
  public void onCreate(Bundle saveInstanceState) {
    super.onCreate(saveInstanceState);
    setContentView(R.layout.day_list_test);
    System.out.println("In day_list_test");

    int Y = 0, M = 0, D = 0;
    Intent getdata = this.getIntent();
    Bundle bd = getdata.getExtras();
    Y = bd.getInt("Year");
    M = bd.getInt("Month");
    D = bd.getInt("Day");
    System.out.println(Y + " " + M + " " + D);

    db = new EventsDao(this);
    ArrayList<Event> data = db.GetOneDayEvents(Y, M, D);
    db.Close();

    System.out.println("close db");
    this.setTitle("Day Event");

    lv = (ListView) findViewById(R.id.show_day_event);
    System.out.println("before array");
    ArrayList<HashMap<String, Object>> day_event = new ArrayList<HashMap<String, Object>>();
    int num_event = 25, initialT = 25, endT = 25;
    if (data.size() > 0) {
      num_event = 0;
      initialT = data.get(num_event).getStartHour();
      endT = data.get(num_event).getEndHour();
    }

    System.out.println("After");
    for (int i = 0; i < 24; i += 1) {
      String event_name = "";
      if (num_event > data.size()) {
        // do not thing
      } else if (endT < i) {
        num_event += 1;
        if (num_event < data.size()) {
          initialT = data.get(num_event).getStartHour();
          endT = data.get(num_event).getEndHour();
        }
      } else if (initialT <= i && endT > i) {
        event_name = data.get(num_event).getName();
      }
      HashMap<String, Object> setData = new HashMap<String, Object>();

      setData.put("time_slot", i);
      setData.put("hour_event", event_name);
      day_event.add(setData);
    }
    SimpleAdapter msimpleAdapter =
        new SimpleAdapter(
            this,
            day_event,
            R.layout.hour_list,
            new String[] {"time_slot", "hour_event"},
            new int[] {R.id.time_slot, R.id.hour_event});
    lv.setAdapter(msimpleAdapter);
  }
Пример #17
0
 @Override
 protected void onCreate(android.os.Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.extra_lesson);
   context = this;
   overridePendingTransition(R.anim.movereturn, 0);
   imgvol = (ImageView) findViewById(R.id.imgELvol);
   imgvol.setOnClickListener(this);
   imgSLexer = (ImageView) findViewById(R.id.imgELexer);
   imgSLexer.setOnClickListener(this);
   imgSLtest = (ImageView) findViewById(R.id.imgELtest);
   imgSLtest.setOnClickListener(this);
   tvExtra_content = (TextView) findViewById(R.id.tvExtra_content);
   tvExtra_lesson = (TextView) findViewById(R.id.tvExtra_lesson);
   imgstory = (ImageView) findViewById(R.id.imgELextra);
   imgstory.setOnClickListener(this);
   imgS = (ImageView) findViewById(R.id.imgE);
   String image = "icon4";
   int drawableResourceId =
       this.getResources().getIdentifier(image, "drawable", this.getPackageName());
   imgS.setImageResource(drawableResourceId);
   previous = (Button) findViewById(R.id.previous);
   previous.setOnClickListener(this);
   database = new MySQLiteOpenHelper(extra_lesson.this);
   arr = database.getAllExtra();
   if (arr.size() != 0) {
     bundle = getIntent().getExtras();
     tvExtra_lesson.setText(arr.get(bundle.getInt("idStory")).getTen());
     tvExtra_content.setText(arr.get(bundle.getInt("idStory")).getNoidung());
   }
 }
 @Override
 public Loader<Cursor> onCreateLoader(int id, Bundle args) {
   Loader loader = null;
   switch (id) {
     case LOADER_PREVIEWS:
       Article.Category category = Article.Category.values()[args.getInt(CATEGORY)];
       int page = args.getInt(PAGE);
       if (category == Article.Category.FAVOURITES)
         loader =
             new CursorLoader(
                 getActivity(),
                 ArticleContract.buildArticlesPreviewListUri(),
                 DatabaseHelper.PREVIEW_COLUMNS,
                 DatabaseHelper.KEY_IS_FAVOURITE + ">0",
                 null,
                 DatabaseHelper.KEY_DATE + " DESC LIMIT " + (page * ARTICLES_PER_PAGE));
       else {
         loader =
             new CursorLoader(
                 getActivity(),
                 ArticleContract.buildArticlesListWithCategoryUri(category),
                 DatabaseHelper.PREVIEW_COLUMNS,
                 null,
                 null,
                 DatabaseHelper.KEY_DATE + " DESC LIMIT " + (page * ARTICLES_PER_PAGE));
       }
       break;
   }
   return loader;
 }
  @SmallTest
  @MediumTest
  @LargeTest
  public void testMultipleCaches() {
    Bundle bundle1 = new Bundle(), bundle2 = new Bundle();

    bundle1.putInt(INT_KEY, 10);
    bundle1.putString(STRING_KEY, "ABC");
    bundle2.putInt(INT_KEY, 100);
    bundle2.putString(STRING_KEY, "xyz");

    ensureApplicationContext();

    SharedPreferencesTokenCachingStrategy cache1 =
        new SharedPreferencesTokenCachingStrategy(getContext());
    SharedPreferencesTokenCachingStrategy cache2 =
        new SharedPreferencesTokenCachingStrategy(getContext(), "CustomCache");

    cache1.save(bundle1);
    cache2.save(bundle2);

    // Get new references to make sure we are getting persisted data.
    // Reverse the cache references for fun.
    cache1 = new SharedPreferencesTokenCachingStrategy(getContext(), "CustomCache");
    cache2 = new SharedPreferencesTokenCachingStrategy(getContext());

    Bundle newBundle1 = cache1.load(), newBundle2 = cache2.load();

    Assert.assertEquals(bundle2.getInt(INT_KEY), newBundle1.getInt(INT_KEY));
    Assert.assertEquals(bundle2.getString(STRING_KEY), newBundle1.getString(STRING_KEY));
    Assert.assertEquals(bundle1.getInt(INT_KEY), newBundle2.getInt(INT_KEY));
    Assert.assertEquals(bundle1.getString(STRING_KEY), newBundle2.getString(STRING_KEY));
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_exercises);
    // t = new Timer();
    // timerMethod();
    userState = PreferenceManager.getDefaultSharedPreferences(this);
    sp = this.getSharedPreferences(userState.getString("username", "username"), 0);
    edit = sp.edit();
    gained_exp = 0;
    exercises_done = 0;
    alert = new AlertDialog.Builder(this);
    intentGlob = getIntent();
    Bundle extras = intentGlob.getExtras();
    currLevel = extras.getInt("LEVEL", 1);
    lastLevel = currLevel;
    currExp = extras.getInt("CURREXP", 0);
    lvlCap = extras.getInt("EXPCAP", 50);
    sv = (ScrollView) findViewById(R.id.svEx);
    setupExercises();

    loadExProgress();
    Toast.makeText(
            this,
            "Remember to stretch/warm up before doing any of the exercises!",
            Toast.LENGTH_SHORT)
        .show();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Utils.Log("MessageFragment onCreate called");

    if (savedInstanceState != null) {
      conversation = new Conversation();
      conversation.setUsername(savedInstanceState.getString("username", ""));
      conversation.setId(savedInstanceState.getInt("_id", 0));
      conversation.setUnreadMessages(savedInstanceState.getInt("unreadMessages", 0));

      // actionBarChangeRequestListener.OnActionBarChangeRequest(Utils.ACTION_BAR_NAME_CHANGE,
      // conversation.getUsername());
      // actionBarChangeRequestListener.OnActionBarChangeRequest(Utils.ACTION_BAR_ENABLE_BACK_BUTTON, null);
    }

    getActivity().setTitle(conversation.username);

    dbManager = new DBManager(getActivity());
    username = dbManager.getUsername();

    dbManager.resetUnreadMessages(conversation.username);

    setHasOptionsMenu(true);
  }
Пример #22
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_survey);

    Bundle b = getIntent().getExtras();
    pId = b.getInt("PLACE_ID");
    depName = (String) b.getCharSequence("DEPENDENCY_NAME");
    depId = b.getInt("DEPENDENT_ID");

    if (depName != null) {
      mSurveyAdapter =
          SurveyAdapterBuilder.getDependentAdapter(this, pId, depId, depName, getFragmentManager());
    } else {
      mSurveyAdapter = SurveyAdapterBuilder.BuildAdapter(this, pId, getFragmentManager());
    }
    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSurveyAdapter);

    // mViewPager.setOnPageChangeListener(new MyPageChangeListener());

    // Bind the title indicator to the adapter
    CirclePageIndicator titleIndicator = (CirclePageIndicator) findViewById(R.id.titles);
    titleIndicator.setViewPager(mViewPager);
    titleIndicator.setOnPageChangeListener(new MyPageChangeListener());
  }
  /**
   * 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);
  }
Пример #24
0
  @Override
  protected final void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
      Bundle bundle = (Bundle) state;

      setMode(Mode.mapIntToValue(bundle.getInt(STATE_MODE, 0)));
      mCurrentMode = Mode.mapIntToValue(bundle.getInt(STATE_CURRENT_MODE, 0));

      mScrollingWhileRefreshingEnabled =
          bundle.getBoolean(STATE_SCROLLING_REFRESHING_ENABLED, false);
      mShowViewWhileRefreshing = bundle.getBoolean(STATE_SHOW_REFRESHING_VIEW, true);

      // Let super Restore Itself
      super.onRestoreInstanceState(bundle.getParcelable(STATE_SUPER));

      State viewState = State.mapIntToValue(bundle.getInt(STATE_STATE, 0));
      if (viewState == State.REFRESHING || viewState == State.MANUAL_REFRESHING) {
        setState(viewState, true);
      }

      // Now let derivative classes restore their state
      onPtrRestoreInstanceState(bundle);
      return;
    }

    super.onRestoreInstanceState(state);
  }
  /*
   * (non-Javadoc)
   *
   * @see android.view.View#onRestoreInstanceState(android.os.Parcelable)
   */
  @Override
  protected void onRestoreInstanceState(final Parcelable state) {
    if (state instanceof Bundle) {
      final Bundle bundle = (Bundle) state;
      setProgress(bundle.getFloat(INSTANCE_STATE_PROGRESS));
      setMarkerProgress(bundle.getFloat(INSTANCE_STATE_MARKER_PROGRESS));

      final int progressColor = bundle.getInt(INSTANCE_STATE_PROGRESS_COLOR);
      if (progressColor != mProgressColor) {
        mProgressColor = progressColor;
        updateProgressColor();
      }

      final int progressBackgroundColor = bundle.getInt(INSTANCE_STATE_PROGRESS_BACKGROUND_COLOR);
      if (progressBackgroundColor != mProgressBackgroundColor) {
        mProgressBackgroundColor = progressBackgroundColor;
        updateBackgroundColor();
      }

      super.onRestoreInstanceState(bundle.getParcelable(INSTANCE_STATE_SAVEDSTATE));
      return;
    }

    super.onRestoreInstanceState(state);
  }
      @Override
      public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();

        if (action.equals("android.intent.action.ServiceToLineChart")) {

          Bundle bundle = intent.getExtras();
          int cmd = bundle.getInt("cmd");

          if (cmd == CMD_RETURN_DATA) {
            templeValue = bundle.getInt("value");
            templeValue = templeValue / (float) 10;

            realTempleTextView.setText("当前温度 " + templeValue + "℃");

            // System.out.println("当前温度 " + templeValue + "℃ " + realButtonRecord.getText());

            generateLineData(nowColor, 0, (float) templeValue);

            sendCmdBroadcast(CMD_GET_DATA, 0); // 请求数据
          } else if (cmd == CMD_FAILED_GET_DATA) {
            sendCmdBroadcast(CMD_GET_DATA, 0); // 请求数据
          } else if (cmd == CMD_RETURN_RECORD_DATA) {
            System.out.println("ooooKK");
            int[] recordMsgBuffer = bundle.getIntArray("buffer");
            // showRecoedData(recordMsgBuffer);
            saveRecordData(recordMsgBuffer);
          }
        }
      }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    init(container, savedInstanceState);
    setHasOptionsMenu(true);
    final View view = inflater.inflate(R.layout.fragment_books_pager, container, false);
    final Bundle extras = getArguments();

    if (extras != null) {
      mBookPosition = extras.getInt(Keys.BOOK_POSITION);
    }

    mBookDetailPager = (ViewPager) view.findViewById(R.id.pager_books);
    mBookDetailPager.setOnPageChangeListener(this);
    mSlidingLayout = (SlidingUpPanelLayout) view.findViewById(R.id.sliding_layout);
    mSlidingLayout.setPanelSlideListener(this);

    mAdapter = new BookPageAdapter(getChildFragmentManager(), null);
    mBookDetailPager.setAdapter(mAdapter);

    if (savedInstanceState == null) {
      final ProfileFragment fragment = new ProfileFragment();

      getChildFragmentManager()
          .beginTransaction()
          .replace(R.id.content_user_profile, fragment, FragmentTags.USER_PROFILE)
          .commit();
    } else {
      mBookPosition = savedInstanceState.getInt(Keys.BOOK_POSITION);
    }

    loadBookSearchResults();

    return view;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    ActionBarUtil.compatibleDeviceWithSB(this);
    requestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY);
    super.onCreate(savedInstanceState);
    ActionBarUtil.setXiaomiFilterDisplayOptions(getSupportActionBar(), false);
    getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_bg_trans));
    Bundle extras = getIntent().getExtras();
    title = extras.getString("title");
    getSupportActionBar().setTitle(title);
    aid = extras.getInt("aid");
    mList = extras.getStringArrayList(EXTRA_IMAGES);
    int index = extras.getInt(EXTRA_INDEX, 0);
    MobclickAgent.onEvent(this, "view_big_pic");
    setContentView(R.layout.activity_images);

    indexText = (TextView) findViewById(R.id.index);
    if (ActionBarUtil.hasSB()
        && getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) {
      setInfoBottomMargin(
          getResources().getDimensionPixelSize(R.dimen.abc_action_bar_default_height));
    }
    pager = (MyViewPager) findViewById(R.id.pager);
    pager.setAdapter(new ImageAdapter(getSupportFragmentManager(), mList));
    pager.setOffscreenPageLimit(1);
    pager.setOnPageChangeListener(this);
    pager.setCurrentItem(index);
    onPageSelected(index);
  }
  @Override
  protected void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
      Bundle bundle = (Bundle) state;

      mMode = Mode.mapIntToMode(bundle.getInt(STATE_MODE, 0));
      mCurrentMode = Mode.mapIntToMode(bundle.getInt(STATE_CURRENT_MODE, 0));

      mDisableScrollingWhileRefreshing =
          bundle.getBoolean(STATE_DISABLE_SCROLLING_REFRESHING, true);
      mShowViewWhileRefreshing = bundle.getBoolean(STATE_SHOW_REFRESHING_VIEW, true);

      // Let super Restore Itself
      super.onRestoreInstanceState(bundle.getParcelable(STATE_SUPER));

      final int viewState = bundle.getInt(STATE_STATE, PULL_TO_REFRESH);
      if (viewState == REFRESHING) {
        setRefreshingInternal(true);
        mState = viewState;
      }
      return;
    }

    super.onRestoreInstanceState(state);
  }
Пример #30
0
 @Override
 public int onStartCommand(Intent intent, int flags, int startId) {
   Bundle bundle = intent.getExtras();
   path = bundle.getString("url"); // 歌曲路径
   current = bundle.getInt("listPosition", -1); // 当前播放歌曲的在mp3Infos的位置
   msg = bundle.getInt("MSG"); // 取出绑定在intent上的操作数值	
   if (msg == AppConstant.PlayerMsg.PLAY_MSG) { // 直接播放音乐
     play(0);
   } else if (msg == AppConstant.PlayerMsg.PAUSE_MSG) { // 暂停
     pause();
   } else if (msg == AppConstant.PlayerMsg.STOP_MSG) { // 停止
     stop();
   } else if (msg == AppConstant.PlayerMsg.CONTINUE_MSG) { // 继续播放
     resume();
   } else if (msg == AppConstant.PlayerMsg.PROGRESS_CHANGE) { // 进度更新
     currentTime = intent.getIntExtra("progress", -1);
     play(currentTime);
   } else if (msg == AppConstant.PlayerMsg.PLAYING_MSG) { // 正在播放
     handler.sendEmptyMessage(2);
   }
   Intent sendIntent = new Intent(UPDATE_ACTION);
   sendIntent.putExtra("current", current);
   sendBroadcast(sendIntent);
   return super.onStartCommand(intent, flags, startId);
 }