Android live video to the main advertisement gift (achieve combo effect)

Source: Internet
Author: User

Introduction to Class libraries

Org.dync.giftlibrary.widget

Giftanimationutil.java Animation class
Giftcontrol.java to externally invoked classes (CORE)
Giftframelayout.java Gift Layout Class
Giftmodel.java populating a gift layout with data classes
The above is a gift animation one (recommended to use the Gift animation one, in the demo Gift1activity.java use)

Leftgiftcontrol.java to externally invoked classes (CORE)
Leftgiftsitemlayout.java Gift Layout Class
Giftmodel.java populating a gift layout with data classes
The above is a gift Animation II (can be used for reference, in the demo Gift2activity.java use)

A personal recommendation is to use a library in the Gift1activity project, and the libraries in the Gift2activity project do not maintain a 1: to GitHub to clone the project locally. 2: Put the Giftlibrary library on your project 3: Add display gifts and gift panels to the XML file you want to display take the Activity_gift1.xml in the project as an example
<?xml version= "1.0" encoding= "Utf-8"?><RelativelayoutXmlns:android="Http://schemas.android.com/apk/res/android"Android:layout_width="Match_parent"android:layout_height="Match_parent" ><ImageViewAndroid:layout_width="Match_parent"android:layout_height="Match_parent"Android:scaletype="Centercrop"Android:src="@mipmap/ic_bg"/><LinearLayoutAndroid:layout_width="Wrap_content"android:layout_height="Wrap_content"android:layout_margintop="100DP"android:orientation="Vertical" ><Org.dync.giftlibrary.widget.GiftFrameLayoutAndroid:id="@+id/gift_layout1"Android:layout_width="Wrap_content"android:layout_height="Wrap_content"/><Org.dync.giftlibrary.widget.GiftFrameLayoutAndroid:id="@+id/gift_layout2"Android:layout_width="Wrap_content"android:layout_height="Wrap_content"/></Linearlayout><ButtonAndroid:id="@+id/action"Android:layout_width="Wrap_content"android:layout_height="Wrap_content"Android:layout_centerhorizontal="True"android:layout_margintop="20DP"android:text= "gift panel show/Hide"/> <linearlayout android:id= "@+id/bottom" android: Layout_width= "match_parent" android:layout_height= "wrap_content" android:layout_alignparentbottom=  "true" android:orientation= " Vertical "> <include layout=< Span class= "Hljs-value" > "@layout/chat_tool_box"/> </ Linearlayout></RELATIVELAYOUT>     

The above giftframelayout is the display of the gift of the control, I only show here two, you can add multiple gifts at the same time, but you need to Giftcontrol class in the corresponding modification code to implement. At the same time the gift panel can use dialogfragment to replace me here.

4: The Gift module can be initialized after the control is found in the activity.

A. Gift panel.
The code is as follows:

new GiftPanelControl(this, mViewpager, mRecyclerView, mDotsLayout);        giftPanelControl.setGiftListener(new GiftPanelControl.GiftListener() {            @Override            public void getGiftStr(String giftStr) { giftstr = giftStr; } });

Here the GIFTSTR parameter I pass is the name of the picture in the resource file, you can also pass the image ID, here is mainly to identify the gift sent.
B. Show gifts
Pass the gift layout control to the gift controller

new GiftControl(Gift1Activity.this);        giftControl.setGiftLayout(giftFrameLayout1, giftFrameLayout2);

C. Panel showing the number of gifts

tvGiftNum.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(final View v) { showGiftDialog(); } });

D. Gift Panel send button to send gift action

Btngift.setonclicklistener (New View.onclicklistener () {@OverridePublicvoidOnClick (View v) {if (Textutils.isempty (giftstr)) {Toast.maketext ( Getapplication (),  "You haven't chosen a present yet", Toast.length_short). Show (); } else {String numstr = Tvgiftnum.gettext (). toString (); if (! Textutils.isempty (NUMSTR)) {int giftnum = Integer.parseint (NUMSTR); if (giftnum = = 0) {return;} else {giftcontrol.loadgift (new Giftmodel (Giftstr,  "Android Robot", Giftnum,  "http://www.baidu.com",  "http://www.baidu.com"); } } } } }); 

E. Simple operation of the screen display different panels
Configuring the activity in Androidmanifest.xml

<activity            android:name=".Gift1Activity"            android:configChanges="orientation|keyboardHidden|screenSize" />

Then rewrite the onconfigurationchanged (Configuration newconfig) method in the activity

@OverridePublicvoidOnconfigurationchanged(Configuration newconfig) {Super.onconfigurationchanged (Newconfig);if (This.getresources (). GetConfiguration (). Orientation = = Configuration.orientation_landscape) {Horizontal screenLOG.E (TAG, "onconfigurationchanged:" + "horizontal screen"); Onconfigurationlandscape (); }else if (this.getResources (). GetConfiguration (). Orientation = = configuration.orientation_portrait) {//Log.e (TAG, " Onconfigurationchanged: "+" vertical screen "); Onconfigurationportrait (); }} private void onconfigurationportrait () {ll_portrait.setvisibility (View.VISIBLE); Ll_ Landscape.setvisibility (View.gone); } private void onconfigurationlandscape () {ll_portrait.setvisibility (View.GONE); Ll_ Landscape.setvisibility (view.visible); }
View.OnClickListener() {            @Override            public void onClick(View view) {                if (giftLayout.getVisibility() == View.VISIBLE) { giftLayout.setVisibility(View.GONE); } else { giftLayout.setVisibility(View.VISIBLE); } } });

Android live video to the main advertisement gift (achieve combo effect)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.