how to integrate pull to refresh feature to android app - android

I made a android app in that it has a listview with rss feeds .so I am trying to implement pull to refresh in my app for loading but I searched for a library I am getting link of [https://github.com/johannilsson/android-pulltorefresh] this .But I don't know How to integrate this library to my android app and I didn't find any jar related to this.please help me.

Recently, Google has implemented PullToRefreshView into its support v4 library. You can find at SwipeRefreshLayout
The implementation is very simple.
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipe_view"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${packageName}.${activityClass}">
<ListView
android:id="#+id/list_view"
android:scrollbarStyle="outsideInset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</android.support.v4.widget.SwipeRefreshLayout>
In your class, you can implement something like this.
mSwipeView.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light,
android.R.color.holo_red_light, android.R.color.holo_orange_light);
mSwipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
#Override public void onRefresh() {
// Your action here
}
});
And cancel it by
mSwipeView.setRefreshing(false);

Related

JiaoZiVideoPlayer player doesn't play anything

I imported this library:
compile 'cn.jzvd:jiaozivideoplayer:6.2.10'
https://github.com/lipangit/JiaoZiVideoPlayer
my view:
<cn.jzvd.JZVideoPlayerStandard
android:id="#+id/videoplayer"
android:layout_width="match_parent"
android:layout_height="200dp"/>
onCreate() function:
JZVideoPlayerStandard jzVideoPlayerStandard = (JZVideoPlayerStandard) findViewById(R.id.videoplayer);
jzVideoPlayerStandard.setUp("https://hw20.cdn.asset.aparat.com/aparat-video/7fd1cf80cc0f254e98f8785d783bf10810811179-144p__81878.mp4",
JZVideoPlayerStandard.SCREEN_WINDOW_NORMAL,
"-");
but it not play my video and it just show a animation loading.
where is my wrong?
Managed to get it to work using this:
In gradle:
implementation 'cn.jzvd:jiaozivideoplayer:6.3.1'
In xml,
<cn.jzvd.JzvdStd
android:id="#+id/video_player"
android:layout_width="match_parent"
android:layout_height="200dp"/>
In java:
JzvdStd jzvdStd = (JzvdStd) rootView.findViewById(R.id.video_player);
jzvdStd.setUp("https://hw20.cdn.asset.aparat.com/aparat-video/7fd1cf80cc0f254e98f8785d783bf10810811179-144p__81878.mp4"
, "How It Works" , Jzvd.SCREEN_WINDOW_NORMAL);
//jzvdStd.thumbImageView.setImage("http://p.qpic.cn/videoyun/0/2449_43b6f696980311e59ed467f22794e792_1/640");
Perhaps the version is different from yours (6.2.10)

Android View.GONE not working as intended on rare occasions

I've been seeing an issue in an app I'm working on relating to views being visible when they shouldn't be and I was wondering if anyone had seen similar.
I have a fragment viewed from a viewPager, that fragment has a base layout, in that base layout I include a banner style area with some info in it and a button, the layout is defaulted to GONE in the XML, like this.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:animateLayoutChanges="true" >
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/usage_swipe_container"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:animateLayoutChanges="true"
android:layout_height="match_parent">
<ScrollView
android:id="#+id/usage_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="#color/background_colour">
<include layout="#layout/layout_in_question"
android:id="#+id/layout_in_question_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"/>
.... Normal Stuff in layout
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
This view is only set to VISIBLE in very select circumstances. However some users are seeing it outside of those circumstances based on a response from a server call, its a very low percentage of users who are seeing it when they shouldn't ( in the region of 0.001% ), the server team insist its not them so I'm trying to ascertain if there are any known android issue or "hacks" that allow this sort of thing. The App supports API 15 and up and we're currently using support libs 25.3.0.
Has anyone seen behavior like this before? are there developer options on some devices that "show all views" or Modded OS's that allow it?
Edit: While I cant share full code snippets due to NDA, I have 2 locations the view can be enabled, both call the same method.
private View onCreateView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState)
{
setupBanner();
}
/**
* OTTO event based on server response
*/
#Subscribe
public void receiveEvent(BannerEvent event)
{
setupBanner();
}
public void setupBanner() {
runOnUiThread(new Runnable() {
#Override
public void run() {
if (shouldShowBanner()) {
findViewById(R.id.layout_in_question_id).setVisibility(View.VISIBLE);
}
}
});
}
shouldShowBanner returns a boolean which is either true/false depending on what the server responded with.

Using Crosswalk in an Android Cordova Project with Embedded WebView

I have an existing Android Cordova project which uses an embedded WebView. What this means is that the Activity does not extend CordovaActivity, but instead embeds the SystemWebView and initializes within the onCreate.
The following is currently how this is being done:
Within the layout XML file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
.... other layout elements not related to Cordova....
<org.apache.cordova.engine.SystemWebView
android:id="#+id/cdvWebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
Within the Activity's onCreate:
SystemWebView systemWebView = (SystemWebView) findViewById(R.id.cdvWebView);
CordovaWebView cdvWebView = new CordovaWebViewImpl(new SystemWebViewEngine(systemWebView));
ConfigXmlParser parser = new ConfigXmlParser();
parser.parse(this);
cdvWebView.init(this, parser.getPluginEntries(), parser.getPreferences());
Due to the bug in Lollipop versions 5.0.+ missing the "set" button, I want to implement the Crosswalk plugin into the project.
Unfortunately, all the documentation I'm finding assumes that a typical Cordova install is being used. I haven't been able to get the embedding and initialization of the XWalkWebView working correctly and keep getting a blank white screen.
Has anybody has success with a similar scenario?
I'm not sure, but this might answer your question. It seems to show implementing an XWalkWebView outside of a typical cordova project:
https://github.com/kurli/crosswalk-website/wiki/How-to-use-Crosswalk-Embedded-API-on-Android

loadUrl() crashes with CordovaWebView

I know that there are some posts here but they are not solving my problem.
The thing is:
I have a Cordova App (android platform). In my activity_main.xml I have declared a CordovaWebView and I want to call loadUrl() method to load a website that is in my assets folder. When I invoke the method the app crashes showing "UNFORTUNATELY, MyApp HAS STOPPED".
STRANGE THINGS I HAVE NOTICED:
If I emulate using a device with API 10 or 16, this WORKS FINE. If I test it with 17 it does NOT WORK.
If I don't use CordovaWebView and directly invoke: this.loadUrl("file:///android_asset/www/index.html"); it works fine, but it's like I am not using the layouts I define (so I don't have my ad banner).
Any ideas about this problem??
Thanks!
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/layout_home"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="#+id/layout_body"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_above="#+id/layout_banner"
android:background="#color/abc_search_url_text_normal">
<org.apache.cordova.CordovaWebView
android:id="#+id/webview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#color/common_signin_btn_dark_text_disabled" />
</LinearLayout>
<RelativeLayout
android:id="#+id/layout_banner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/wallet_hint_foreground_holo_dark">
</RelativeLayout>
</RelativeLayout>
MainAcitivy.java
public class MainActivity extends CordovaActivity {
CordovaWebView cwv;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
..LOAD ADVERTISEMENT INTO LAYOUT_BANNER...
cwv = (CordovaWebView) findViewById(R.id.webview);
cwv.getSettings().setJavaScriptEnabled(true);
cwv.loadUrl("file:///android_asset/www/index.html");
}
look the doc : https://cordova.apache.org/docs/en/3.5.0/guide_platforms_android_webview.md.html
cwv = (CordovaWebView) findViewById(R.id.cordovaview);
Config.init(this);
cwv.loadUrl(Config.getStartUrl());
you can see a sample here : https://github.com/dam1/sample-android-cordova-webview
Why do you need activity_main.xml and all android stuff, just start a fresh project using cordova command line. You don't need any xml of that sort in standard cordova project.
You've got cordova plugins for displaying admob ads inside cordova web view, see http://plugreg.com/search?q=admob

Using API for opening a chatroom - Scringo Android

I am using Scringo for implementing Group Chat within my Android App. Is there a way in which we can open a particular chatroom through code ? Right now, from the sample applications and API, I found only the below code.
Scringo.openChatRooms(MainActivity.this);
Please let me know how do I
Create a Chatroom programmatically
Open a particular Chatroom programmatically.
Right now Scringo SDK is not providing way to open a chatroom programmatically. They are having their own screens(Activity) to manage the many to many Chat functionality. They are yet to integrate the following features on their Android SDK.
1. Creating Chatrooms programmatically
2. Joining/Opening Chatrooms programmatically
Source: I got a response from their Support Team. They claim that this feature is available for their IOS sdk. I am not sure.
This code solved my problem :
MainActivity.java
public class MainActivity extends Activity {
private Scringo scringo;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
scringo = new Scringo(this);
...
findViewById(R.id.openChatRoomButton).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
Scringo.openChatRooms(MainActivity.this);
}
});
...
}
main.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
...
<Button
android:id="#+id/openChatRoomButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:text="#string/open_inbox_button_text" />
</RelativeLayout>

Categories

Resources