InternetConnection

A Android library That Simplify Connecting To Internet

License

License

Categories

Categories

Net
GroupId

GroupId

com.github.peymanfarajnezhad
ArtifactId

ArtifactId

internetconnection
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

aar
Description

Description

InternetConnection
A Android library That Simplify Connecting To Internet
Project URL

Project URL

https://github.com/peymanfarajnezhad/InternetConnection
Source Code Management

Source Code Management

https://github.com/peymanfarajnezhad/InternetConnection

Download internetconnection

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.peymanfarajnezhad/internetconnection/ -->
<dependency>
    <groupId>com.github.peymanfarajnezhad</groupId>
    <artifactId>internetconnection</artifactId>
    <version>0.0.1</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.peymanfarajnezhad/internetconnection/
implementation 'com.github.peymanfarajnezhad:internetconnection:0.0.1'
// https://jarcasting.com/artifacts/com.github.peymanfarajnezhad/internetconnection/
implementation ("com.github.peymanfarajnezhad:internetconnection:0.0.1")
'com.github.peymanfarajnezhad:internetconnection:aar:0.0.1'
<dependency org="com.github.peymanfarajnezhad" name="internetconnection" rev="0.0.1">
  <artifact name="internetconnection" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.github.peymanfarajnezhad', module='internetconnection', version='0.0.1')
)
libraryDependencies += "com.github.peymanfarajnezhad" % "internetconnection" % "0.0.1"
[com.github.peymanfarajnezhad/internetconnection "0.0.1"]

Dependencies

compile (1)

Group / Artifact Type Version
com.android.support » appcompat-v7 jar 26.0.0-alpha1

Project Modules

There are no modules declared in this project.

Internet Connection

An Android library That Simplify Connecting to the Internet and Download files.

features

  • send POST request
  • sent FILE with request
  • get result as a string
  • downloader with perfect dialog
  • sequence downloader

Usage

In the first stage, you need to include these permissions in your AndroidManifest.xml file

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

After that, import com.zhillamo.internet package in your packages folder. So now everything is ready to start.

Samples

post request sample:

HttpRequest request = new HttpRequest();
request.url("http://www.zhillamo.com/");
request.cacheExpireTime(120000);
request.cacheDir(DIR_APP);
request.enableCache(true);
request.addPostField("key1", "test value");
request.addPostField("key2", intValue);
request.addFileField("key3", new File(DIR_APP, "file_name.ex"));
request.listener(new HttpConnector.webListener() {
                    @Override
                    public void onSuccess(String result) {
                        Log.i(result);
                    }
        
                    @Override
                    public void onError(String errorMessage) {
                        Log.e(errorMessage);
                    }
                });
request.build();

HttpConnector connector = new HttpConnector(request);
connector.connect();

downloader sample:

    //if yours files more than one so create list of FileStruct
    List<FileStruct> soundLinks = new ArrayList<>();
    
    Downloader downloader = new Downloader.Builder(activityContext)
        .title("DIALOG TITLE")
        .font(TYPEFACE)
        .showSize(true) //show file size during download ex: 1.23MB of 5.2MB
        .showDialog(true) //show progress dilaog of download
        .addUrls(soundLinks) //list of files
        .addUrl("FILE_URL", "FILE_PATH") //single file
        .listener(new Downloader.Listener() {
           @Override
           public void onPreDownload() {
              //do somethings before start download
           }

           @Override
           public void onProgressUpdate(long totalFiles, long fileIndex, long percent) {
              //progress update
           }

           @Override
           public void onComplete() {
              //complete download
           }

           @Override
           public void onError(int totalFilesCount, List<FileStruct> errorFiles) {
              //do something when have error
           }

           @Override
           public void onCancel() {
                //do somethings when user cancelled download.
           }
        })
        .build();
    downloader.start();

Versions

Version
0.0.1