A very simple arc layout library for Android
Include the ArcLayout widget in your layout
Programming is very interesting and creative thing if you do it with love. This blog code helps a lot to beginners to learn programming from basic to advance level. I really love this blog because I learn a lot from here and this process is still continuing.
boolean
, byte
, short
, char
, int
, long
, float
, double
) are fully stored on the thread stack and are thus not visible to other threads. One thread may pass a copy of a pritimive variable to another thread, but it cannot share the primitive local variable itself.Byte
, Integer
, Long
etc.). It does not matter if an object was created and assigned to a local variable, or created as a member variable of another object, the object is still stored on the heap.Local Variable 2
) point to a shared object on the heap (Object 3). The two threads each have a different reference to the same object. Their references are local variables and are thus stored in each thread's thread stack (on each). The two different references point to the same object on the heap, though.public class MyRunnable implements Runnable() {
public void run() {
methodOne();
}
public void methodOne() {
int localVariable1 = 45;
MySharedObject localVariable2 =
MySharedObject.sharedInstance;
//... do more with local variables.
methodTwo();
}
public void methodTwo() {
Integer localVariable1 = new Integer(99);
//... do more with local variable.
}
}
public class MySharedObject {
//static variable pointing to instance of MySharedObject
public static final MySharedObject sharedInstance =
new MySharedObject();
//member variables pointing to two objects on the heap
public Integer object2 = new Integer(22);
public Integer object4 = new Integer(44);
public long member1 = 12345;
public long member1 = 67890;
}
run()
method then the diagram shown earlier would be the outcome. The run()
method calls methodOne()
and methodOne()
calls methodTwo()
.methodOne()
declares a primitive local variable (localVariable1
of type int
) and an local variable which is an object reference (localVariable2
).methodOne()
will create its own copy of localVariable1
and localVariable2
on their respective thread stacks. The localVariable1
variables will be completely separated from each other, only living on each thread's thread stack. One thread cannot see what changes another thread makes to its copy of localVariable1
.methodOne()
will also create their own copy of localVariable2
. However, the two different copies of localVariable2
both end up pointing to the same object on the heap. The code setslocalVariable2
to point to an object referenced by a static variable. There is only one copy of a static variable and this copy is stored on the heap. Thus, both of the two copies of localVariable2
end up pointing to the same instance of MySharedObject
which the static variable points to. The MySharedObject
instance is also stored on the heap. It corresponds to Object 3 in the diagram above.MySharedObject
class contains two member variables too. The member variables themselves are stored on the heap along with the object. The two member variables point to two otherInteger
objects. These Integer
objects correspond to Object 2 and Object 4 in the diagram above.methodTwo()
creates a local variable named localVariable1
. This local variable is an object reference to an Integer
object. The method sets the localVariable1
reference to point to a newInteger
instance. The localVariable1
reference will be stored in one copy per thread executingmethodTwo()
. The two Integer
objects instantiated will be stored on the heap, but since the method creates a new Integer
object every time the method is executed, two threads executing this method will create separate Integer
instances. The Integer
objects created inside methodTwo()
correspond to Object 1 and Object 5 in the diagram above.MySharedObject
of type long
which is a primitive type. Since these variables are member variables, they are still stored on the heap along with the object. Only local variables are stored on the thread stack.volatile
declarations or synchronization, updates to the shared object made by one thread may not be visible to other threads.count
variable to 2. This change is not visible to other threads running on the right CPU, because the update to count
has not been flushed back to main memory yet.volatile
keyword can make sure that a given variable is read directly from main memory, and always written back to main memory when updated.count
of a shared object into its CPU cache. Imagine too, that thread B does the same, but into a different CPU cache. Now thread A adds one to count
, and thread B does the same. Now var1
has been incremented two times, once in each CPU cache.count
would be been incremented twice and had the original value + 2 written back to main memory.count
back to main memory, the updated value will only be 1 higher than the original value, despite the two increments.com.bdlibslidinguppanel.SlidingUpPanelLayout
as the root element in your activity layout.gravity
set to either top
or bottom
.match_parent
.match_parent
and the height set to either match_parent
, wrap_content
or the max desireable height. If you would like to define the height as the percetange of the screen, set it tomatch_parent
and also define a layout_weight
attribute for the sliding view.setDragView
method or umanoDragView
attribute.<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoPanelHeight="68dp"
sothree:umanoShadowHeight="4dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Main Content"
android:textSize="16sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|top"
android:text="The Awesome Sliding Up Panel"
android:textSize="16sp" />
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
windowActionBarOverlay
is set to true
in your styles:<style name="AppTheme">
<item name="android:windowActionBarOverlay">true</item>
</style>
?android:attr/actionBarSize
or ?attr/actionBarSize
to support older API versions.umanoDragView
, the panel will pass through the click events to the main layout. Make your second layout clickable
to prevent this.setPanelHeight
method or umanoPanelHeight
attribute.shadowHeight
attribute to 0.setEnabled(false)
to completely disable the sliding panel (including touch and programmatic sliding)setTouchEnabled(false)
to disables panel's touch responsiveness (drag and click), you can still control the panel programaticallygetPanelState
to get the current panel statesetPanelState
to set the current panel stateumanoParallaxOffset
attribute (see demo for the example).setAnchorPoint
to allow an intermediate expanded state for the panel (similar to Google Maps).PanelSlideListener
to monitor events about sliding panes.layout_gravity
attribute of the layout to top
.umanoScrollInterpolator
attribute. For instance, if you want a bounce or overshoot effect for the panel.setOverlayed
method or umanoOverlay
attribute. This is useful if you would like to make the sliding layout semi-transparent. You can also set umanoClipPanel
to false to make the panel transparent in non-overlay mode.umanoFadeColor
. Set it to "@android:color/transparent"
to remove dimming completely.umanoScrollableView
attribute on the panel to supported nested scrolling. The panel supports ListView
, ScrollView
and RecyclerView
out of the box, but you can add support for any type of a scrollable view by setting a custom ScrollableViewHelper
. Here is an example forNestedScrollView
public class NestedScrollableViewHelper extends ScrollableViewHelper {
public int getScrollableViewScrollPosition(View scrollableView, boolean isSlidingUp) {
if (mScrollableView instanceof NestedScrollView) {
if(isSlidingUp){
return mScrollableView.getScrollY();
} else {
NestedScrollView nsv = ((NestedScrollView) mScrollableView);
View child = nsv.getChildAt(0);
return (child.getBottom() - (nsv.getHeight() + nsv.getScrollY()));
}
} else {
return 0;
}
}
}
setScrollableViewHelper
on the sliding panel.
State
|
Description
|
Running
|
Activity is visible and interacts with the user.
|
Paused
|
Activity is still visible but partially obscured,
instance is running but might be killed by the system.
|
Stopped
|
Activity is not visible, instance is running but might
be killed by the system.
|
Killed
|
Activity has been terminated by the system of by a call
to its
finish() method. |
Method
|
Purpose
|
onCreate()
|
Called then the activity is created. Used to initialize
the activity, for example create the user interface.
|
onResume()
|
Called if the activity get
visible again and the user starts interacting with the activity again. Used
to initialize fields, register listeners, bind to services, etc.
|
onPause()
|
Called once another activity gets into the foreground.
Always called before the activity is
not visible anymore. Used to release resources or save application data. For
example you unregister listeners, intent receivers, unbind from services or
remove system service listeners.
|
onStop()
|
Called once the activity is no longer visible. Time or
CPU intensive shut-down operations, such as writing information to a database
should be down in the
onStop() method. This method is guaranteed to be called as of
API 11. |