I want to display a simple list of names in a list view. But I'm not able to figure out how. I think I'll not be able to use a modal class since all the values in JSON will have same property called students. My JSON data on firebase looks like this on firebse
{
"physicsClass":{
"students":["John","Frank","Allen"]
},
"chemistryClass":{
"students":["Gillen","Jason","David East"]
}
}
When I run the it crashes with the following error log:
com.google.firebase.database.DatabaseException: Failed to convert value of type java.util.ArrayList to String
at com.google.android.gms.internal.zzaix.zzaC(Unknown Source)
at com.google.android.gms.internal.zzaix.zzb(Unknown Source)
at com.google.android.gms.internal.zzaix.zza(Unknown Source)
at com.google.firebase.database.DataSnapshot.getValue(Unknown Source)
at com.firebase.ui.database.FirebaseListAdapter.parseSnapshot(FirebaseListAdapter.java:113)
at com.firebase.ui.database.FirebaseListAdapter.getItem(FirebaseListAdapter.java:102)
at com.firebase.ui.database.FirebaseListAdapter.getView(FirebaseListAdapter.java:130)
at android.widget.AbsListView.obtainView(AbsListView.java:2346)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1281)
at android.widget.ListView.onMeasure(ListView.java:1188)
at android.view.View.measure(View.java:18794)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
at android.view.View.measure(View.java:18794)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
at android.view.View.measure(View.java:18794)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:391)
at android.view.View.measure(View.java:18794)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18794)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18794)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
at android.view.View.measure(View.java:18794)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Suggest any other way of implementing the above data in a list view / recycler view.
I'm using the firebase-ui sdk to display data in the listview. Below is the code
DatabaseReference ref = FirebaseDatabase.getInstance().getReference();
DatabaseReference sezRef = ref.child("physics");
studentList = (ListView)findViewById(R.id.studentList);
firebaseListAdapter = new FirebaseListAdapter<String>(this,String.class,android.R.layout.simple_list_item_1,phyRef) {
#Override
protected void populateView(View v, String model, int position) {
TextView textView = (TextView)v.findViewById(android.R.id.text1);
textView.setText(model);
}
};studentList.setAdapter(firebaseListAdapter);
The error Failed to convert value of type means that when you retrieve you object from Firebase snapshot, you try to get the information as a String but the data in the snapshot is actually an ArrayList. That is why Firebase throws a DatabaseException.
Related
If I ran the app normally it would work just fine,when I put a breakpoint on if statement in setUserVisibleHint(),it crashes with exception: java.lang.IllegalStateException: No activity.
So what's gonna be the problem?
public class MyFragment extends Fragment
public MyFragment() {
// Required empty public constructor
}
public static CommunityFragment newInstance() {
Bundle args = new Bundle();
MyFragment fragment = new MyFragment();
fragment.setArguments(args);
return fragment;
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_community, container, false);
}
#Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (getActivity() != null && isVisibleToUser) {
// fragment is visible
}
} else if (getActivity() != null) {
// fragment is invisible
}
}
}
}
logcat:
E/AndroidRuntime: FATAL EXCEPTION: main
PID: 8669
java.lang.IllegalStateException: No activity
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1578)
at android.support.v4.app.FragmentManagerImpl.dispatchCreate(FragmentManager.java:2883)
at android.support.v4.app.Fragment.onCreate(Fragment.java:1268)
at android.support.v4.app.Fragment.performCreate(Fragment.java:2177)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1244)
at android.support.v4.app.FragmentTransition.addToFirstInLastOut(FragmentTransition.java:1080)
at android.support.v4.app.FragmentTransition.calculateFragments(FragmentTransition.java:971)
at android.support.v4.app.FragmentTransition.startTransitions(FragmentTransition.java:95)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2143)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2098)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1979)
at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:626)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1268)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1116)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1642)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:714)
at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:786)
at android.view.View.measure(View.java:18788)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
at android.view.View.measure(View.java:18788)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android
Instead of
if (getActivity() != null && isVisibleToUser) {
// fragment is visible
}
} else if (getActivity() != null) {
// fragment is invisible
}
try with
if (getView() != null) {
// fragment is visible
}
It worked for me.
I get ConcurrentModificationException in my RecyclerView, only in APIs 23 & 26, how can I bypass this?
This is my RecyclerView Setup:
private void setUpRecyclerView() {
int maxIndex = 0;
if (game.size() < 3) {
maxIndex = game.size();
} else if (game.size() >= 3) {
maxIndex = 3;
}
recyclerView = findViewById(R.id.home_recycler_view);
adapter = new GameCardListMiniAdapter(this, game.subList(0, maxIndex));
recyclerView.setAdapter(adapter);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(ActivityHome.this);
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
}
after I manipulate the data from game, I call recyclerView.swapAdapter(adapter, true); and get the error, but only in the afore mentioned APIs, in the rest of the APIs up to API 15 everything works just fine.
This is the stacktrace for API 23:
E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa0d2a5a0
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.racu.cardgame, PID: 26900
java.util.ConcurrentModificationException
at java.util.AbstractList$SubAbstractList.size(AbstractList.java:360)
at com.example.racu.cardgame.adapters.cardgameListMiniAdapter.getItemCount(cardgameListMiniAdapter.java:68)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3603)
at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3103)
at android.view.View.measure(View.java:18788)
at android.support.v4.widget.NestedScrollView.measureChildWithMargins(NestedScrollView.java:1446)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.support.v4.widget.NestedScrollView.onMeasure(NestedScrollView.java:512)
at android.view.View.measure(View.java:18788)
at android.support.constraint.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:934)
at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:973)
at android.view.View.measure(View.java:18788)
at android.support.constraint.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:934)
at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:973)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18788)
at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1060)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
at android.view.View.measure(View.java:18788)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygot
This is for API 26:
D/EGL_emulation: eglMakeCurrent: 0x9d2e70a0: ver 2 0 (tinfo 0xa8e8b510)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.racu.cardgame, PID: 4691
java.util.ConcurrentModificationException
at java.util.ArrayList$SubList.size(ArrayList.java:1057)
at com.example.racu.cardgame.adapters.cardgameListMiniAdapter.getItemCount(cardgameListMiniAdapter.java:68)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3603)
at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3103)
at android.view.View.measure(View.java:21998)
at android.support.v4.widget.NestedScrollView.measureChildWithMargins(NestedScrollView.java:1446)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.support.v4.widget.NestedScrollView.onMeasure(NestedScrollView.java:512)
at android.view.View.measure(View.java:21998)
at android.support.constraint.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:934)
at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:973)
at android.view.View.measure(View.java:21998)
at android.support.constraint.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:934)
at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:973)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:21998)
at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1060)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:721)
at android.view.View.measure(View.java:21998)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2410)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1498)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1751)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1386)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6733)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
08-14 18:50:44.793 4691-4691/com.example.racu.cardgame E/AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Tried to make it work creating the game.SubList outside,with a for loop instead of a SubList, didn't crash, but swapAdapter wasn't being called and the most strange thing is that is working wonderful in my phone, no crashes and the expected behavior.
I really,really apreciate some light.
Regards Ne0R#Cu
The root of this issue is that List.subList() does not copy the List:
/**
* Returns a view of the portion of this list between the specified
* fromIndex, inclusive, and toIndex, exclusive. (If
* fromIndex and toIndex are equal, the returned list is
* empty.) The returned list is backed by this list, so non-structural
...
Then, when you call size() on the resulting view, the exception is thrown. I haven't dug into why this happened, but size() tries to validate it's current size, which in this case is conflicted between the full list and the view.
So, you can remedy this crash by simply copying the list:
List<YOUR_TYPE> trimmed = new ArrayList<>( game.subList(0, maxIndex) );
adapter = new GameCardListMiniAdapter(this, trimmed);
Try
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
instead of :
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(ActivityHome.this);
then do the same thing ext
rc.setHasFixedSize(false);//only use this for fixed ammount
rc.setLayoutManager(layoutManager);
rc.setAdapter(dataItemAdapter);
I could not find any answer for my question, I ended up creating a HorizontalScrollView and adding my views from code to a LinearLayout within the HorizontalScrollView.
I'm trying to retrieve the objectId as a string from my User class in Parse, but I'm getting a NullPointer.
Log.w(getClass().toString(), ParseUser.getCurrentUser().getParseObject("currentGroup").getObjectId());
java.lang.NullPointerException: println needs a message
I'm querying the column "currentGroup", which is a pointer to a class called "Group". All I want is to retrieve its objectId. Both the currentGroup and Group objectId columns have data. They are not null. What's going on here?
Error:
It seems to think the object is null but I can't see why it would be.
java.lang.NullPointerException: Attempt to invoke virtual method
'java.lang.String com.parse.ParseObject.getObjectId()' on a null object reference
at at com.yitter.android.fragment.FeedFragment.retrieveData(FeedFragment.java:112)
at com.yitter.android.fragment.FeedFragment.onCreateView(FeedFragment.java:105)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2080)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1108)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1290)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:801)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1638)
at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:679)
at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:166)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1240)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1088)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1614)
at android.view.View.measure(View.java:18794)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
at android.view.View.measure(View.java:18794)
at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1085)
at android.view.View.measure(View.java:18794)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
at android.view.View.measure(View.java:18794)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18794)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18794)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18794)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
at android.view.View.measure(View.java:18794)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
ParseQuery<ParseObject> query = ParseQuery.getQuery("Orders");
ParseObject obj = ParseObject.createWithoutData("ShopLocations",idd); // this pointer object class name and pointer value
query.whereEqualTo("shop", obj); // this pointer object and parse object
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> object, ParseException e) {
if (e == null) {}}
This is working correctly retrieving data from parse.
I found the solution. You can not retrieve the object of a pointer using ParseUser.getCurrentUser(). You have to do a full ParseUser query to retrieve the current User, by finding the user in your User table with an objectId equal to ParseUser.getCurrentUser().getObjectId().
ParseQuery query = ParseUser.getQuery();
query.whereEqualTo("objectId", ParseUser.getCurrentUser().getObjectId());
query.findInBackground(new FindCallback() {
#Override
public void done(List<ParseObject> users, ParseException e) {
if (e == null) for (userObject : users) {
// I retrieve the objectId from the pointer
// only after directly querying for the current User.
userObject.getParseObject("currentGroup").getObjectId();
}
}
});
At least, this is the only way I managed to get this to work in my app. I'm not sure why the .getParseObject() method is available to ParseUser.getCurrentUser() if you can't just directly retrieve the objectId of the specified pointer object, but oh well. If anyone knows, I'd love to know how you did it.
Good morning.
My app is crashing once it is published on the Google Play Store, and then installed from it. If I install my app from Android Studio, it won't crash at all.
The app seems to be crashing when I try to open a layout that grabs information from a local db made with RushORM.
This is what the ANRs reports on the GP Console:
ANR Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 35. Wait queue head age: 5507.1ms.)
And this is what the Crashes reports on the GP Console:
a.a.a.b.b.c: This is most likely caused by a change in data structure or new RushObject.
This issue should be resolved by a database migration.
This can be done by updating db version number in the manifest or setting Rush in debug mode.
To set Rush in debug mode add this to your manifest file - <meta-data android:name="Rush_debug" android:value="true" />
at a.a.a.a.j.b(Unknown Source)
at a.a.a.b.n.a(Unknown Source)
at a.a.a.b.n.a(Unknown Source)
at a.a.a.b.al.b(Unknown Source)
at com.avena.avenafit.dashboard.g.L(Unknown Source)
at com.avena.avenafit.dashboard.g.a(Unknown Source)
at com.avena.avenafit.dashboard.ad.a(Unknown Source)
at b.a.a.a.c.a(Unknown Source)
at com.avena.avenafit.dashboard.ad.a(Unknown Source)
at android.support.v4.app.af.a(Unknown Source)
at android.support.v4.app.af.a(Unknown Source)
at android.support.v4.app.j.run(Unknown Source)
at android.support.v4.app.af.e(Unknown Source)
at android.support.v4.app.af.b(Unknown Source)
at android.support.v4.app.ap.b(Unknown Source)
at android.support.v4.view.ViewPager.a(Unknown Source)
at android.support.v4.view.ViewPager.c(Unknown Source)
at android.support.v4.view.ViewPager.onMeasure(Unknown Source)
at android.view.View.measure(View.java:18794)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.support.design.widget.CoordinatorLayout.a(Unknown Source)
at android.support.design.widget.CoordinatorLayout.onMeasure(Unknown Source)
at android.view.View.measure(View.java:18794)
at android.support.v4.widget.DrawerLayout.onMeasure(Unknown Source)
at android.view.View.measure(View.java:18794)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.support.v7.widget.ContentFrameLayout.onMeasure(Unknown Source)
at android.view.View.measure(View.java:18794)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18794)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18794)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18794)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
at android.view.View.measure(View.java:18794)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I already tried changing my DB version like this on my Manifest file:
<!-- Updating this will cause a database upgrade -->
<meta-data
android:name="Rush_db_version"
android:value="2" />
Now, if I have the app installed from the GPStore, and I have Android Studio open, I see lots of weird errors registered. Of all of those, this one gets my attention:
07-11 11:17:08.037 17067-17067/com.avena.avenafit E/SQLiteLog: (1) no such column: type_of_check
type_of_check if a field on one of my db structures (as I mentioned, made with RushORM). For reference, here's my class:
package com.avena.avenafit.dbb;
import co.uk.rushorm.core.RushObject;
public class UserCheck extends RushObject {
private String type_of_check;
private String check_date;
private String hour_checked;
/* Classes must include an empty constructor */
public UserCheck() {}
public String getType_of_check() {
return type_of_check;
}
public void setType_of_check(String type_of_check) {
this.type_of_check = type_of_check;
}
public String getCheck_date() {
return check_date;
}
public void setCheck_date(String check_date) {
this.check_date = check_date;
}
public String getHour_checked() {
return hour_checked;
}
public void setHour_checked(String hour_checked) {
this.hour_checked = hour_checked;
}
}
And here's an example where I set the type_of_check:
breakfast.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
try {
String time =
new SimpleDateFormat("HH:mm", Locale.getDefault()).format(date);
sendCheck("check_breakfast");
breakfast.setColorFilter(color_green);
UserCheck check1 = new UserCheck();
check1.setType_of_check("1");
check1.setCheck_date(currentDate);
check1.setHour_checked(time.toString());
check1.save();
} catch (JSONException e) {
e.printStackTrace();
}
}
});
Does anyone see what I'm missing here?
RushOrm only requires this one line to work with ProGuard.
-keep public class * implements co.uk.rushorm.core.Rush { *; }
The reason why it's implements Rush is because RushObject which you extend implements Rush itself.
Classes can work with RushOrm by directly implementing Rush instead of extending RushObject which is why this is the best way to use it with ProGuard
Thanks
This function:
public Uri convertURI(Context context, Bitmap bitmap){
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
String path = MediaStore.Images.Media.insertImage(context.getContentResolver(), bitmap, "Profile", null);
return Uri.parse(path);
}
The created URI path is this when I send it through an intent into another activity as a string:
02-02 22:02:54.471 23398-23398/recruitr.recruitr E/cand_uri_string: content://media/external/images/media/76268
Now when I try to use the URI to access the image again, I get this (using the universal image loader library) - it can't find the image:
02-02 22:04:07.597 24662-24662/recruitr.recruiter E/AndroidRuntime: FATAL EXCEPTION: main
Process: recruitr.recruitr, PID: 24662
java.lang.NullPointerException: Attempt to read from field 'com.nostra13.universalimageloader.core.DisplayImageOptions com.nostra13.universalimageloader.core.ImageLoaderConfiguration.defaultDisplayImageOptions' on a null object reference
at com.nostra13.universalimageloader.core.ImageLoader.loadImageSync(ImageLoader.java:597)
at com.nostra13.universalimageloader.core.ImageLoader.loadImageSync(ImageLoader.java:543)
at recruitr.recruitr.CandidateProfile.CandidateProfilePreview_Fragment.onCreateView(CandidateProfilePreview_Fragment.java:84)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1965)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1078)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1259)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1624)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1106)
at android.support.v4.view.ViewPager.populate(ViewPager.java:952)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1474)
at android.view.View.measure(View.java:18795)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:610)
at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:677)
at android.view.View.measure(View.java:18795)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.support.v7.internal.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
at android.view.View.measure(View.java:18795)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18795)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18795)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18795)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2658)
at android.view.View.measure(View.java:18795)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.
Does anyone know why this may be?
Try these lines of code for loading image on the Imageview using Universal imageloader using URI
private final DisplayImageOptions options;
private final ImageLoader imageLoader;
imageLoader = ImageLoader.getInstance();
ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(activity));
options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.loader)
.showImageForEmptyUri(R.drawable.loader)
.showImageOnFail(R.drawable.loader)
.cacheInMemory(true)
.cacheOnDisk(true)
.considerExifParams(true)
.bitmapConfig(Bitmap.Config.RGB_565)
.build();
You have to use the "file://" in displayImage method of Univeral Imageloader
imageLoader.displayImage("file://" + YOUR_URI_HERE, YOUR_IMAGEVIEW, options, null);