Exemplo n.º 1
0
 @Override
 public void onHiddenChanged(boolean hidden) {
   super.onHiddenChanged(hidden);
   if (!hidden) {
     handleAddButtonFromNew();
   }
 }
Exemplo n.º 2
0
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == Activity.RESULT_OK) {
      switch (requestCode) {
        case REQUEST_SELECT_IMAGE:
          if (data != null) {
            loadImageIntoCatroid(data);
          }
          break;
        case REQUEST_POCKET_PAINT_EDIT_IMAGE:
          if (data != null) {
            loadPocketPaintImageIntoCatroid(data);
          }
          break;
        case REQUEST_TAKE_PICTURE:
          String defLookName = getString(R.string.default_look_name);
          lookFromCameraUri = UtilCamera.rotatePictureIfNecessary(lookFromCameraUri, defLookName);
          loadPictureFromCameraIntoCatroid();
          break;
      }

      isResultHandled = true;
    }
  }
Exemplo n.º 3
0
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    listView = getListView();
    registerForContextMenu(listView);

    if (savedInstanceState != null) {
      selectedLookData =
          (LookData) savedInstanceState.getSerializable(BUNDLE_ARGUMENTS_SELECTED_LOOK);

      boolean uriIsSet = savedInstanceState.getBoolean(BUNDLE_ARGUMENTS_URI_IS_SET);
      if (uriIsSet) {
        String defLookName = getString(R.string.default_look_name);
        lookFromCameraUri = UtilCamera.getDefaultLookFromCameraUri(defLookName);
      }
    }
    lookDataList = ProjectManager.INSTANCE.getCurrentSprite().getLookDataList();

    adapter =
        new LookAdapter(getActivity(), R.layout.fragment_look_looklist_item, lookDataList, false);
    adapter.setOnLookEditListener(this);
    setListAdapter(adapter);

    Utils.loadProjectIfNeeded(getActivity());
  }
Exemplo n.º 4
0
  @Override
  public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, view, menuInfo);

    selectedLookData = adapter.getItem(selectedLookPosition);
    menu.setHeaderTitle(selectedLookData.getLookName());

    getSherlockActivity().getMenuInflater().inflate(R.menu.context_menu_default, menu);
    menu.findItem(R.id.context_edit_in_pocket_paint).setVisible(true);
  }
Exemplo n.º 5
0
  @Override
  public void onResume() {
    super.onResume();

    if (!Utils.checkForExternalStorageAvailableAndDisplayErrorIfNot(getActivity())) {
      return;
    }

    if (lookRenamedReceiver == null) {
      lookRenamedReceiver = new LookRenamedReceiver();
    }

    if (lookDeletedReceiver == null) {
      lookDeletedReceiver = new LookDeletedReceiver();
    }

    IntentFilter intentFilterRenameLook = new IntentFilter(ScriptActivity.ACTION_LOOK_RENAMED);
    getActivity().registerReceiver(lookRenamedReceiver, intentFilterRenameLook);

    IntentFilter intentFilterDeleteLook = new IntentFilter(ScriptActivity.ACTION_LOOK_DELETED);
    getActivity().registerReceiver(lookDeletedReceiver, intentFilterDeleteLook);

    SharedPreferences settings =
        PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());

    setShowDetails(settings.getBoolean(SHARED_PREFERENCE_NAME, false));

    handleAddButtonFromNew();

    if (isResultHandled) {
      isResultHandled = false;

      ScriptActivity scriptActivity = (ScriptActivity) getActivity();
      if (scriptActivity.getIsLookFragmentFromSetLookBrickNew()
          && scriptActivity.getIsLookFragmentHandleAddButtonHandled()) {
        switchToScriptFragment();
      }
    }
  }
Exemplo n.º 6
0
  @Override
  public void onPause() {
    super.onPause();

    ProjectManager projectManager = ProjectManager.getInstance();
    if (projectManager.getCurrentProject() != null) {
      projectManager.saveProject();
    }

    if (lookDeletedReceiver != null) {
      getActivity().unregisterReceiver(lookDeletedReceiver);
    }

    if (lookRenamedReceiver != null) {
      getActivity().unregisterReceiver(lookRenamedReceiver);
    }

    SharedPreferences settings =
        PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
    SharedPreferences.Editor editor = settings.edit();

    editor.putBoolean(SHARED_PREFERENCE_NAME, getShowDetails());
    editor.commit();
  }
Exemplo n.º 7
0
 @Override
 public void onStart() {
   super.onStart();
   initClickListener();
 }
Exemplo n.º 8
0
 @Override
 public void onSaveInstanceState(Bundle outState) {
   outState.putBoolean(BUNDLE_ARGUMENTS_URI_IS_SET, (lookFromCameraUri != null));
   outState.putSerializable(BUNDLE_ARGUMENTS_SELECTED_LOOK, selectedLookData);
   super.onSaveInstanceState(outState);
 }