Java Code Examples for org.parceler.Parcels#unwrap()

The following examples show how to use org.parceler.Parcels#unwrap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupActivity.java    From talk-android with MIT License 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
        switch (requestCode) {
            case EDIT_GROUP_NAME_REQUEST:
                if (data != null) {
                    Group group = Parcels.unwrap(data.getParcelableExtra(EditGroupNameActivity.GROUP));
                    if (group != null) {
                        mAdapter.updateOne(group);
                        GroupRealm.getInstance().addOrUpdate(group)
                                .subscribe(new EmptyAction<Group>(), new RealmErrorAction());
                    }
                }
                break;
        }
    }
}
 
Example 2
Source File: FavoritesPhotoViewActivity.java    From talk-android with MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    msgId = getIntent().getExtras().getString("msgId");
    searchData = Parcels.unwrap(getIntent().getExtras().getParcelable("data"));
    searchData.type = "file";

    presenter = new SearchPresenter(this);

    if (msgId != null && searchData != null) {
        originPage = searchData.page;
        leftPage = searchData.page;
        rightPage = searchData.page;
        presenter.searchFavorites(searchData);
    }
}
 
Example 3
Source File: LoginActivity.java    From talk-android with MIT License 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK && requestCode == REQUEST_TEAMBITION_CODE) {
        String code = data.getStringExtra(UnionsActivity.CODE);
        TalkClient.getInstance().getAccountApi()
                .signInByTeambition(code)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<User>() {
                    @Override
                    public void call(User user) {
                        if (StringUtil.isNotBlank(user.getAccountToken())) {
                            RegisterActivity.initUserData(LoginActivity.this, user);
                            TransactionUtil.goTo(LoginActivity.this, ChooseTeamActivity.class, true);
                        }
                    }
                }, new ApiErrorAction());
    } else if (resultCode == RESULT_OK && requestCode == REQUEST_COUNTRY_CODE) {
        if (data != null) {
            CountryModel model = Parcels.unwrap(data.getParcelableExtra(PickCountryCodeActivity.COUNTRY_CODE_DATA));
            tvCountryCode.setText("+ " +  String.valueOf(model.callingCode));
        }
    }
}
 
Example 4
Source File: ChatActivity.java    From talk-android with MIT License 6 votes vote down vote up
private void initArgs(Intent intent) {
    teamId = intent.getStringExtra(TEAM_ID);
    if (StringUtil.isBlank(teamId)) {
        teamId = BizLogic.getTeamId();
    }
    member = Parcels.unwrap(intent.getParcelableExtra(EXTRA_MEMBER));
    room = Parcels.unwrap(intent.getParcelableExtra(EXTRA_ROOM));
    story = Parcels.unwrap(intent.getParcelableExtra(EXTRA_STORY));
    message = Parcels.unwrap(intent.getParcelableExtra(EXTRA_MESSAGE));
    isQuit = intent.getBooleanExtra("is_quit", false);
    isArchive = intent.getBooleanExtra(IS_ARCHIVE, false);
    if (story != null) {
        StoryRealm.getInstance().addOrUpdate(story).subscribe(new EmptyAction<Story>(), new RealmErrorAction());
    }
    if (message != null) {
        isSearchResult = true;
        if (BizLogic.isMe(message.get_creatorId())) {
            member = MainApp.globalMembers.get(message.get_toId());
        } else {
            member = MainApp.globalMembers.get(message.get_creatorId());
        }
        room = message.getRoom();
    }
    isPreview = getIntent().getBooleanExtra(IS_PREVIEW, false);
    isPrivate = (member != null && room == null && story == null);
}
 
Example 5
Source File: EditGroupNameActivity.java    From talk-android with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_group_name);
    ButterKnife.inject(this);

    setSupportActionBar(mToolbar);
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle("");
    group = Parcels.unwrap(getIntent().getParcelableExtra(GROUP));
    if (group != null) {
        mGroupNameEdit.setText(group.getName());
    }
}
 
Example 6
Source File: GroupMemberActivity.java    From talk-android with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
        switch (requestCode) {
            case CHOOSE_MEMBER_REQUEST:
                if (data != null) {
                    List<Member> members = Parcels.unwrap(data.getParcelableExtra(ChooseMemberActivity.MEMBERS));
                    addMember(members);
                }
                break;
        }
    }
}
 
Example 7
Source File: SearchedSessionsActivity.java    From droidkaigi2016 with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_searched_sessions);
    getComponent().inject(this);

    SearchGroup searchGroup = Parcels.unwrap(getIntent().getParcelableExtra(SearchGroup.class.getSimpleName()));

    initToolbar(searchGroup);
    AppUtil.setTaskDescription(this, searchGroup.getName(), AppUtil.getThemeColorPrimary(this));

    if(savedInstanceState == null) {
        replaceFragment(SearchedSessionsFragment.newInstance(searchGroup));
    }
}
 
Example 8
Source File: ViewKino.java    From CineLog with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == RESULT_ADD_REVIEW) {
        if (resultCode == Activity.RESULT_OK) {
            kino = Parcels.unwrap(data.getParcelableExtra("kino"));
            editted = true;
            System.out.println("Result Ok");
        }
        if (resultCode == Activity.RESULT_CANCELED) {
            System.out.println("Result Cancelled");
        }
    }
}
 
Example 9
Source File: TopicStoryFragment.java    From talk-android with MIT License 5 votes vote down vote up
@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    overlay = activity.findViewById(R.id.view_overlay);
    this.isExpanded = getArguments().getBoolean("isExpanded", false);
    this.story = Parcels.unwrap(getArguments().getParcelable("story"));
    topic = GsonProvider.getGson().fromJson(story.getData(), Topic.class);
    if (MainApp.globalMembers.containsKey(story.get_creatorId())) {
        creator = MainApp.globalMembers.get(story.get_creatorId());
    } else {
        creator = MemberDataProcess.getAnonymousInstance();
    }
    BusProvider.getInstance().register(this);
}
 
Example 10
Source File: ViewSerie.java    From CineLog with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == RESULT_ADD_REVIEW && resultCode == Activity.RESULT_OK) {
        kino = Parcels.unwrap(data.getParcelableExtra("kino"));
        generalFragment.updateKino((SerieDto) kino);
    }
}
 
Example 11
Source File: SessionsTabFragment.java    From droidkaigi2016 with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case REQ_DETAIL:
            if (resultCode == Activity.RESULT_OK) {
                Session session = Parcels.unwrap(data.getParcelableExtra(Session.class.getSimpleName()));
                if (session != null) {
                    adapter.refresh(session);
                    onChangeSessionListener.onChangeSession(Collections.singletonList(session));
                }
            }
            break;
    }
}
 
Example 12
Source File: HomeActivity.java    From PainlessMusicPlayer with Apache License 2.0 5 votes vote down vote up
@Override
protected void onRestoreInstanceState(@NonNull final Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    final HomeViewModel state = Parcels.unwrap(
            savedInstanceState.getParcelable(KEY_INSTANCE_STATE));
    if (state != null) {
        viewModel.applyFrom(state);
    }
}
 
Example 13
Source File: SerieViewEpisodesFragment.java    From CineLog with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_serie_view_episodes, container, false);
    ButterKnife.bind(this, view);

    serie_view_episodes_progress_bar.setVisibility(View.VISIBLE);
    this.serieDto = Parcels.unwrap(getActivity().getIntent().getParcelableExtra("kino"));

    new SerieEpisodesNetworkTask(this).execute(this.serieDto.getTmdbKinoId().intValue());

    return view;
}
 
Example 14
Source File: SessionsTabFragment.java    From droidkaigi2016 with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    sessions = Parcels.unwrap(getArguments().getParcelable(ARG_SESSIONS));
}
 
Example 15
Source File: Proxmark3TuneResultActivity.java    From Walrus with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_proxmark3_tune_results);

    Proxmark3Device.TuneResult tuneResult = Parcels.unwrap(getIntent().getParcelableExtra(
            EXTRA_TUNE_RESULT));

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    if (tuneResult.lf) {
        setResultInfo(tuneResult.peakV, 2.948f, 14.730f, R.id.lfOk);
        ((TextView) findViewById(R.id.lf125)).setText(
                getResources().getString(R.string.tune_voltage, tuneResult.v125));
        ((TextView) findViewById(R.id.lf134)).setText(
                getResources().getString(R.string.tune_voltage, tuneResult.v134));
        ((TextView) findViewById(R.id.lfOptimal)).setText(
                getResources().getString(R.string.tune_peak_voltage, tuneResult.peakV,
                        (tuneResult.peakF / 1000)));

        LineChart lfChart = findViewById(R.id.lfChart);
        if (tuneResult.lfVoltages != null) {
            List<Entry> entries = new ArrayList<>();
            for (int i = 255; i >= 19; --i) {
                entries.add(new Entry(12e6f / (i + 1) / 1e3f, tuneResult.lfVoltages[i]));
            }

            LineDataSet lineDataSet = new LineDataSet(entries, getString(R.string.lf));
            lineDataSet.setColor(Color.BLACK);
            lineDataSet.setCircleColor(Color.BLUE);

            LineData lineData = new LineData(lineDataSet);

            lfChart.setData(lineData);
            lfChart.setDescription(null);
            lfChart.getLegend().setEnabled(false);
            lfChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);
            lfChart.getAxisRight().setEnabled(false);
            lfChart.invalidate();
        } else {
            lfChart.setVisibility(View.GONE);
        }
    } else {
        findViewById(R.id.lf).setVisibility(View.GONE);
    }

    if (tuneResult.hf) {
        setResultInfo(tuneResult.hfVoltage, 3.167f, 7.917f, R.id.hfOk);
        ((TextView) findViewById(R.id.hfV)).setText(
                getResources().getString(R.string.tune_voltage, tuneResult.hfVoltage));
    } else {
        findViewById(R.id.hf).setVisibility(View.GONE);
    }
}
 
Example 16
Source File: SettingsActivity.java    From PainlessMusicPlayer with Apache License 2.0 4 votes vote down vote up
private void restoreInstanceState(@Nullable final Bundle instanceState) {
    if (instanceState != null) {
        final InstanceState state = Parcels.unwrap(instanceState.getParcelable(EXTRA_STATE));
        suppressDayNightWarnings = state.suppressDayNightWarnings;
    }
}
 
Example 17
Source File: SearchResultFragment.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  getFragmentComponent(savedInstanceState).inject(this);
  CrashReport crashReport = CrashReport.getInstance();

  if (viewModel == null && savedInstanceState != null && savedInstanceState.containsKey(
      VIEW_MODEL)) {
    viewModel = Parcels.unwrap(savedInstanceState.getParcelable(VIEW_MODEL));
  } else if (viewModel == null && getArguments().containsKey(VIEW_MODEL)) {
    viewModel = Parcels.unwrap(getArguments().getParcelable(VIEW_MODEL));
  }

  if (savedInstanceState != null && savedInstanceState.containsKey(FOCUS_IN_SEARCH)) {
    focusInSearchBar = savedInstanceState.getBoolean(FOCUS_IN_SEARCH);
  } else if (getArguments().containsKey(FOCUS_IN_SEARCH) && savedInstanceState == null) {
    focusInSearchBar = getArguments().getBoolean(FOCUS_IN_SEARCH);
  }

  if (viewModel != null) {
    currentQuery = viewModel.getSearchQueryModel()
        .getFinalQuery();
  }

  final AptoideApplication application = (AptoideApplication) getActivity().getApplication();

  noResults = false;
  networkError = false;

  onItemViewClickRelay = PublishRelay.create();
  onAdClickRelay = PublishRelay.create();
  suggestionClickedPublishSubject = PublishSubject.create();
  searchSetupPublishSubject = PublishSubject.create();
  queryTextChangedPublisher = PublishSubject.create();

  showingSearchResultsView = PublishSubject.create();
  noResultsAdultContentSubject = PublishSubject.create();
  noResultsPublishSubject = PublishSubject.create();

  final List<SearchAppResult> searchResultFollowedStores = new ArrayList<>();
  final List<SearchAdResult> searchResultAdsFollowedStores = new ArrayList<>();

  followedStoresResultAdapter =
      new SearchResultAdapter(onAdClickRelay, onItemViewClickRelay, searchResultFollowedStores,
          searchResultAdsFollowedStores, crashReport, oneDecimalFormatter);

  listItemPadding = getResources().getDimension(R.dimen.padding_tiny);

  final List<SearchAppResult> searchResultAllStores = new ArrayList<>();
  final List<SearchAdResult> searchResultAdsAllStores = new ArrayList<>();

  allStoresResultAdapter =
      new SearchResultAdapter(onAdClickRelay, onItemViewClickRelay, searchResultAllStores,
          searchResultAdsAllStores, crashReport, oneDecimalFormatter);

  searchSuggestionsAdapter =
      new SearchSuggestionsAdapter(new ArrayList<>(), suggestionClickedPublishSubject);
  searchTrendingAdapter =
      new SearchSuggestionsAdapter(new ArrayList<>(), suggestionClickedPublishSubject);

  setHasOptionsMenu(true);
}
 
Example 18
Source File: SearchActivity.java    From droidkaigi2016 with Apache License 2.0 4 votes vote down vote up
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    statusChangedSessions = Parcels.unwrap(savedInstanceState.getParcelable(RESULT_STATUS_CHANGED_SESSIONS));
}
 
Example 19
Source File: GroupMemberActivity.java    From talk-android with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_group_member);

    ButterKnife.inject(this);
    setSupportActionBar(mToolbar);
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(R.string.group_manager);

    mGroup = Parcels.unwrap(getIntent().getParcelableExtra(GROUP));
    mAdapter = new GroupMemberAdapter(mGroup);

    final LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    mRecyclerView.setLayoutManager(manager);
    mRecyclerView.setAdapter(mAdapter);

    List<String> memberIds = Parcels.unwrap(getIntent().getParcelableExtra(MEMBER_IDS));
    MemberRealm.getInstance().getMembersByIds(memberIds)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Action1<List<Member>>() {
                @Override
                public void call(List<Member> members) {
                    mAdapter.setMembers(members);
                }
            }, new RealmErrorAction());
    mAdapter.setOnRemoveListener(this);
    mAdapter.setOnItemClickListener(this);

    mSearchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            mAdapter.filter(newText);
            return false;
        }
    });
}
 
Example 20
Source File: MemberListParcelConverter.java    From talk-android with MIT License 4 votes vote down vote up
@Override
public Member itemFromParcel(Parcel parcel) {
    return Parcels.unwrap(parcel.readParcelable(Member.class.getClassLoader()));
}