本文整理汇总了Java中org.parceler.Parcels.unwrap方法的典型用法代码示例。如果您正苦于以下问题:Java Parcels.unwrap方法的具体用法?Java Parcels.unwrap怎么用?Java Parcels.unwrap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.parceler.Parcels
的用法示例。
在下文中一共展示了Parcels.unwrap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import org.parceler.Parcels; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_step_detail);
setSupportActionBar(mBinding.stepDetailToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (getIntent() != null) {
if (getIntent().hasExtra(STEP_EXTRA)){
step = Parcels.unwrap(getIntent().getParcelableExtra(STEP_EXTRA));
getSupportActionBar().setTitle(step.getShortDescription());
}
}
if (savedInstanceState != null) {
fragment = (StepDetailFragment) getSupportFragmentManager().getFragment(savedInstanceState, "stepDetailFragment");
} else {
fragment = StepDetailFragment.newInstance(step, true);
getSupportFragmentManager().beginTransaction().replace(R.id.step_fragment_container, fragment).commit();
}
}
示例2: onActivityResult
import org.parceler.Parcels; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == NEW_TRIP_REQUEST) {
if (data != null && data.hasExtra("TRIP")) {
Parcelable par = data.getParcelableExtra("TRIP");
Trip t = Parcels.unwrap(par);
topRef.push().setValue(t);
Snackbar.make(toolbar, "New Trip Added", Snackbar.LENGTH_SHORT).show();
}
}
else
super.onActivityResult(requestCode, resultCode, data);
}
示例3: onCreate
import org.parceler.Parcels; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_media_view);
ButterKnife.bind(this);
imgLoader = new FirebaseImageLoader();
storage = FirebaseStorage.getInstance();
Intent incoming = getIntent();
if (incoming.hasExtra("JRNL_ENTRY")) {
Parcelable parcel = incoming.getParcelableExtra("JRNL_ENTRY");
entry = Parcels.unwrap(parcel);
switch (entry.getType()) {
case 1:
break;
case 2:
videoView.setVisibility(View.GONE);
break;
case 3:
case 4:
photoView.setVisibility(View.GONE);
initExoPlayer();
break;
}
}
}
示例4: getPlate
import org.parceler.Parcels; //导入方法依赖的package包/类
public Plate getPlate() {
Bundle arguments = fragment.getArguments();
if (arguments == null) {
return null;
}
return Parcels.unwrap(arguments.getParcelable(PLATE_BUNDLE_KEY));
}
示例5: onCreate
import org.parceler.Parcels; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_journal_edit);
ButterKnife.bind(this);
Intent incoming = getIntent();
imgLoader = new FirebaseImageLoader();
FirebaseStorage storage = FirebaseStorage.getInstance();
if (incoming.hasExtra("JRNL_ENTRY")) {
Parcelable parcel = incoming.getParcelableExtra("JRNL_ENTRY");
entry = Parcels.unwrap(parcel);
String url = null;
if (entry.getType() == 2) {
url = entry.getUrl();
fabCover.setVisibility(View.VISIBLE);
}
else if (entry.getType() == 3) {
fabCover.setVisibility(View.GONE);
imageView.setImageResource(R.drawable.transparent_box);
}
else if (entry.getType() == 4) {
url = entry.getThumbnailUrl();
fabCover.setVisibility(View.GONE);
}
if (url != null) {
Glide.with(this)
.using(imgLoader)
.load(storage.getReferenceFromUrl(url))
.into(this.imageView);
}
caption.setText(entry.getCaption());
dateTime.setText(entry.getDate());
}
if (incoming.hasExtra("DB_REF")) {
String ref = incoming.getStringExtra("DB_REF");
parentRef = FirebaseDatabase.getInstance().getReferenceFromUrl(ref);
String entryKey = incoming.getStringExtra("JRNL_KEY");
myRef = parentRef.child("entries").child(entryKey);
}
}
示例6: onCreateView
import org.parceler.Parcels; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_step, container, false);
stepsAdapter = new StepsAdapter(getContext(), this);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
mBinding.rvSteps.setLayoutManager(layoutManager);
mBinding.rvSteps.setAdapter(stepsAdapter);
// steps = new ArrayList<>();
Bundle args = getArguments();
long recipeId = args.getLong("RECIPE_ID", -1);
if (recipeId != -1) {
RecipeDatabaseHelper recipeDatabaseHelper = new RecipeDatabaseHelper(getContext());
recipeDatabaseHelper.getRecipe(recipeId, this);
}
if(args.containsKey(STEPS_EXTRA)) {
for (Parcelable parcelable : args.getParcelableArrayList(STEPS_EXTRA)) {
Step step = Parcels.unwrap(parcelable);
// steps.add(step);
stepsAdapter.addStep(step);
}
}
if (savedInstanceState != null){
if (savedInstanceState.containsKey(SCROLLBAR_POSITION_KEY)){
mBinding.rvSteps.scrollToPosition(savedInstanceState.getInt(SCROLLBAR_POSITION_KEY));
}
}
return mBinding.getRoot();
}
示例7: onCreateView
import org.parceler.Parcels; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_main, container, false);
recipeAdapter = new RecipeAdapter(getContext(), this);
recipeDatabaseHelper = new RecipeDatabaseHelper(getContext());
recipeApiClient = new RecipeApiClient();
recipes = new ArrayList<>();
getIdlingResource();
mBinding.swiperefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener(){
@Override
public void onRefresh() {
updateRecipes();
}
});
GridAutofitLayoutManager layoutManager = new GridAutofitLayoutManager(getContext(), 800);
mBinding.rvRecipes.setLayoutManager(layoutManager);
mBinding.rvRecipes.setAdapter(recipeAdapter);
mBinding.rvRecipes.setHasFixedSize(false);
if (savedInstanceState != null){
if (savedInstanceState.containsKey(SAVED_RECIPES_KEY)){
ArrayList<Parcelable> recipeParcelableArrayList = savedInstanceState.getParcelableArrayList(SAVED_RECIPES_KEY);
for (Parcelable parcelable : recipeParcelableArrayList){
Recipe recipe = Parcels.unwrap(parcelable);
recipes.add(recipe);
recipeAdapter.addRecipe(recipe);
}
}
if (savedInstanceState.containsKey(SCROLLBAR_POSITION_KEY)){
int position = savedInstanceState.getInt(SCROLLBAR_POSITION_KEY);
mBinding.rvRecipes.getLayoutManager().scrollToPosition(position);
}
} else {
mBinding.pbLoadingIndicator.setVisibility(View.VISIBLE);
recipeDatabaseHelper.getAllRecipes(this);
}
return mBinding.getRoot();
}
示例8: onCreate
import org.parceler.Parcels; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_journal_view);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
entries.setLayoutManager(new LinearLayoutManager(this));
Retrofit retro = new Retrofit.Builder()
.baseUrl("https://api.darksky.net/")
.addConverterFactory(GsonConverterFactory.create())
.build();
darkSkyClient = retro.create(DarkSkyServices.class);
Intent incoming = getIntent();
if (incoming.hasExtra("TRIP")) {
Parcelable par = incoming.getParcelableExtra("TRIP");
Trip t = Parcels.unwrap(par);
tripKey = t.getKey();
title.setText(t.getName());
FirebaseDatabase dbRef = FirebaseDatabase.getInstance();
FirebaseAuth auth = FirebaseAuth.getInstance();
FirebaseUser user = auth.getCurrentUser();
entriesRef = dbRef.getReference(user.getUid())
.child(tripKey + "/entries").orderByChild("date");
storage = FirebaseStorage.getInstance();
adapter = new MyAdapter();
entries.setAdapter(adapter);
entries.addItemDecoration(verticalGap);
}
}
示例9: onCreate
import org.parceler.Parcels; //导入方法依赖的package包/类
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
PhotoModel model = Parcels.unwrap(bundle.getParcelable(EXTRA_PHOTO));
iImageLoader.loadImage(model.getImgSrc(), ivPhoto);
commentPresenter.loadData(String.valueOf(model.getId()));
} else {
finish();
}
}
}
示例10: onCreate
import org.parceler.Parcels; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_journal_edit);
ButterKnife.bind(this);
Intent incoming = getIntent();
imgLoader = new FirebaseImageLoader();
FirebaseStorage storage = FirebaseStorage.getInstance();
if (incoming.hasExtra("JRNL_ENTRY")) {
Parcelable parcel = incoming.getParcelableExtra("JRNL_ENTRY");
entry = Parcels.unwrap(parcel);
String url = null;
if (entry.getType() == 2) {
url = entry.getUrl();
fabCover.setVisibility(View.VISIBLE);
}
else if (entry.getType() == 4) {
url = entry.getThumbnailUrl();
fabCover.setVisibility(View.GONE);
}
if (url != null) {
Glide.with(this)
.using(imgLoader)
.load(storage.getReferenceFromUrl(url))
.into(this.imageView);
}
caption.setText(entry.getCaption());
dateTime.setText(entry.getDate());
}
if (incoming.hasExtra("DB_REF")) {
String ref = incoming.getStringExtra("DB_REF");
parentRef = FirebaseDatabase.getInstance().getReferenceFromUrl(ref);
String entryKey = incoming.getStringExtra("JRNL_KEY");
myRef = parentRef.child("entries").child(entryKey);
}
}
示例11: get
import org.parceler.Parcels; //导入方法依赖的package包/类
@Override
public Object get(String s, Bundle bundle) {
return Parcels.unwrap(bundle.getParcelable(s));
}
示例12: onCreate
import org.parceler.Parcels; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_journal_view);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
entries.setLayoutManager(new LinearLayoutManager(this));
FirebaseImageLoader imgLoader = new FirebaseImageLoader();
Intent incoming = getIntent();
if (incoming.hasExtra("TRIP")) {
Parcelable par = incoming.getParcelableExtra("TRIP");
Trip t = Parcels.unwrap(par);
tripKey = t.getKey();
title.setText(t.getName());
FirebaseDatabase dbRef = FirebaseDatabase.getInstance();
FirebaseAuth auth = FirebaseAuth.getInstance();
FirebaseUser user = auth.getCurrentUser();
entriesRef = dbRef.getReference(user.getUid())
.child(tripKey + "/entries");
storage = FirebaseStorage.getInstance();
adapter = new FirebaseRecyclerAdapter<JournalEntry, EntryHolder>
(JournalEntry.class, R.layout.journal_entry_item,
EntryHolder.class, entriesRef) {
@Override
protected void populateViewHolder(EntryHolder viewHolder, JournalEntry model, int position) {
viewHolder.setCaption(model.getCaption());
viewHolder.setDate(model.getDate());
switch (model.getType()) {
case 1:
viewHolder.mediaContainer.setVisibility(View
.GONE);
break;
case 2: // photo
viewHolder.topImage.setVisibility(View.VISIBLE);
viewHolder.playIcon.setVisibility(View.GONE);
Glide.with(viewHolder.topImage.getContext())
.using(imgLoader)
.load(storage.getReferenceFromUrl(model.getUrl()))
.into(viewHolder.topImage);
break;
case 3: // audio
viewHolder.topImage.setVisibility(View.VISIBLE);
viewHolder.playIcon.setVisibility(View.VISIBLE);
break;
case 4: // video
viewHolder.topImage.setVisibility(View.VISIBLE);
viewHolder.playIcon.setVisibility(View.VISIBLE);
Glide.with(viewHolder.topImage.getContext())
.using(imgLoader)
.load(storage.getReferenceFromUrl
(model.getThumbnailUrl()))
.into(viewHolder.topImage);
break;
default:
viewHolder.topImage.setVisibility(View.GONE);
break;
}
viewHolder.editBtn.setOnClickListener( view -> {
String key = getRef(position).getKey();
toMediaEdit(model, key);
});
viewHolder.topImage.setOnClickListener( view -> {
toMediaView(model);
});
viewHolder.playIcon.setOnClickListener( view -> {
toMediaView(model);
});
}
};
entries.setAdapter(adapter);
entries.addItemDecoration(verticalGap);
}
}
示例13: onCreate
import org.parceler.Parcels; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_journal_view);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
entries.setLayoutManager(new LinearLayoutManager(this));
FirebaseImageLoader imgLoader = new FirebaseImageLoader();
Intent incoming = getIntent();
if (incoming.hasExtra("TRIP")) {
Parcelable par = incoming.getParcelableExtra("TRIP");
Trip t = Parcels.unwrap(par);
tripKey = t.getKey();
title.setText(t.getName());
FirebaseDatabase dbRef = FirebaseDatabase.getInstance();
FirebaseAuth auth = FirebaseAuth.getInstance();
FirebaseUser user = auth.getCurrentUser();
entriesRef = dbRef.getReference(user.getUid())
.child(tripKey + "/entries");
storage = FirebaseStorage.getInstance();
adapter = new FirebaseRecyclerAdapter<JournalEntry, EntryHolder>
(JournalEntry.class, R.layout.journal_entry_item,
EntryHolder.class, entriesRef) {
@Override
protected void populateViewHolder(EntryHolder viewHolder, JournalEntry model, int position) {
viewHolder.setCaption(model.getCaption());
viewHolder.setDate(model.getDate());
switch (model.getType()) {
case 2: // photo
viewHolder.topImage.setVisibility(View.VISIBLE);
viewHolder.playIcon.setVisibility(View.GONE);
Glide.with(viewHolder.topImage.getContext())
.using(imgLoader)
.load(storage.getReferenceFromUrl(model.getUrl()))
.into(viewHolder.topImage);
break;
case 4: // video
viewHolder.topImage.setVisibility(View.VISIBLE);
viewHolder.playIcon.setVisibility(View.VISIBLE);
Glide.with(viewHolder.topImage.getContext())
.using(imgLoader)
.load(storage.getReferenceFromUrl
(model.getThumbnailUrl()))
.into(viewHolder.topImage);
break;
default:
viewHolder.topImage.setVisibility(View.GONE);
break;
}
viewHolder.editBtn.setOnClickListener( view -> {
String key = getRef(position).getKey();
toMediaEdit(model, key);
});
viewHolder.topImage.setOnClickListener( view -> {
toMediaView(model);
});
}
};
entries.setAdapter(adapter);
}
}
示例14: onCreate
import org.parceler.Parcels; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_journal);
ButterKnife.bind(this);
Intent data = getIntent();
if (data.hasExtra("TRIP")) {
toolbar.setTitle("Edit Journal");
Parcelable par = data.getParcelableExtra("TRIP");
currentTrip = Parcels.unwrap(par);
FirebaseAuth auth = FirebaseAuth.getInstance();
String uid = auth.getCurrentUser().getUid();
DatabaseReference ref = FirebaseDatabase.getInstance()
.getReference(uid).child(currentTrip.getKey())
.child("entries");
photoFrag = PhotoFragment.newInstance(ref.toString());
getSupportFragmentManager().beginTransaction()
.add(R.id.container, photoFrag)
.commit();
jname.setText(currentTrip.getName());
location.setText(currentTrip.getLocation());
startDateView.setText(formatted(DateTime.parse(currentTrip
.getStartDate())));
endDateView.setText(formatted(DateTime.parse(currentTrip.getEndDate())));
startDate = DateTime.parse(currentTrip.getStartDate());
endDate = DateTime.parse(currentTrip.getEndDate());
} else {
toolbar.setTitle("New Journal");
currentTrip = new Trip();
DateTime today = DateTime.now();
startDateView.setText(formatted(today));
endDateView.setText(formatted(today.plusDays(1)));
startDate = today;
endDate = today.plusDays(1);
}
dpDialog = DatePickerDialog.newInstance(this,
startDate.getYear(), startDate.getMonthOfYear() - 1, startDate
.getDayOfMonth());
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
示例15: onCreateView
import org.parceler.Parcels; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_step_detail, container, false);
mPlayerView = mBinding.exoPlayer;
if (getArguments() != null){
step = Parcels.unwrap(getArguments().getParcelable(STEP_EXTRA));
}
if (step != null){
if (step.getVideoURL() != null && !step.getVideoURL().isEmpty()){
playWhenReady = getArguments().getBoolean(PLAY_EXTRA, false);
mBinding.flStepDetailFragment.setVisibility(View.VISIBLE);
mBinding.ivStepThumbnail.setVisibility(View.INVISIBLE);
mBinding.exoPlayer.setVisibility(View.VISIBLE);
initializeMediaSession();
initializePlayer(Uri.parse(step.getVideoURL()));
} else if (step.getThumbnailURL() != null && !step.getThumbnailURL().isEmpty()){
mBinding.flStepDetailFragment.setVisibility(View.VISIBLE);
mBinding.exoPlayer.setVisibility(View.INVISIBLE);
mBinding.ivStepThumbnail.setVisibility(View.VISIBLE);
Glide.with(getContext())
.load(step.getThumbnailURL())
.apply(new RequestOptions()
.placeholder(R.drawable.placeholder_food)
.fallback(R.drawable.placeholder_food)
.centerCrop())
.transition(DrawableTransitionOptions.withCrossFade())
.into(mBinding.ivStepThumbnail);
} else {
mBinding.flStepDetailFragment.setVisibility(View.VISIBLE);
mBinding.exoPlayer.setVisibility(View.INVISIBLE);
mBinding.ivStepThumbnail.setVisibility(View.VISIBLE);
Glide.with(getContext())
.load(R.drawable.placeholder_food)
.apply(new RequestOptions()
.centerCrop())
.transition(DrawableTransitionOptions.withCrossFade())
.into(mBinding.ivStepThumbnail);
}
mBinding.tvStepDetails.setText(step.getDescription());
}
return mBinding.getRoot();
}