Skip to content

Commit 20830e2

Browse files
committed
incomplete task
0 parents  commit 20830e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1477
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.externalNativeBuild

.idea/compiler.xml

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copyright/profiles_settings.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 24
5+
buildToolsVersion "25.0.0"
6+
defaultConfig {
7+
applicationId "co.megaminds.p1exam"
8+
minSdkVersion 11
9+
targetSdkVersion 24
10+
versionCode 1
11+
versionName "1.0"
12+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25+
exclude group: 'com.android.support', module: 'support-annotations'
26+
})
27+
compile 'com.android.support:appcompat-v7:24.2.1'
28+
compile 'com.android.support:recyclerview-v7:24.2.1'
29+
testCompile 'junit:junit:4.12'
30+
31+
// for Retrofit and GSON library
32+
compile 'com.squareup.retrofit2:retrofit:2.1.0'
33+
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
34+
}

app/proguard-rules.pro

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /home/hasan/Android/Sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package co.megaminds.p1exam;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("co.megaminds.p1exam", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="co.megaminds.p1exam">
3+
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
7+
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme">
9+
<activity android:name=".Activity.MainActivity">
10+
<intent-filter>
11+
<action android:name="android.intent.action.MAIN" />
12+
13+
<category android:name="android.intent.category.LAUNCHER" />
14+
</intent-filter>
15+
</activity>
16+
</application>
17+
18+
</manifest>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package co.megaminds.p1exam.Activity;
2+
3+
import android.os.Bundle;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.support.v7.widget.LinearLayoutManager;
6+
import android.support.v7.widget.RecyclerView;
7+
import android.widget.Toast;
8+
9+
import java.util.Collections;
10+
import java.util.List;
11+
12+
import co.megaminds.p1exam.Adapter.HorizontalAdapter;
13+
import co.megaminds.p1exam.HelperClasses.NetworkCheckingClass;
14+
import co.megaminds.p1exam.Interface.ApiInterface;
15+
import co.megaminds.p1exam.Model.JsonData;
16+
import co.megaminds.p1exam.Model.Popular;
17+
import co.megaminds.p1exam.R;
18+
import co.megaminds.p1exam.Retrofit.RetrofitApiClient;
19+
import retrofit2.Call;
20+
import retrofit2.Callback;
21+
import retrofit2.Response;
22+
23+
public class MainActivity extends AppCompatActivity {
24+
25+
RecyclerView recyclerView;
26+
List<Popular> popularList;
27+
private ApiInterface apiInterface;
28+
29+
@Override
30+
protected void onCreate(Bundle savedInstanceState) {
31+
super.onCreate(savedInstanceState);
32+
setContentView(R.layout.activity_main);
33+
34+
recyclerView = (RecyclerView) findViewById(R.id.horizontal_recycler_view);
35+
popularList = Collections.<Popular>emptyList();
36+
apiInterface = RetrofitApiClient.getClient().create(ApiInterface.class);
37+
38+
if(NetworkCheckingClass.isNetworkAvailable(this))
39+
fetchData();
40+
else
41+
Toast.makeText(this, "No internet Connection", Toast.LENGTH_LONG).show();
42+
43+
}
44+
45+
private void fetchData() {
46+
47+
48+
49+
Call<JsonData> call = apiInterface.apiCall();
50+
call.enqueue(new Callback<JsonData>() {
51+
@Override
52+
public void onResponse(Call<JsonData> call, Response<JsonData> response) {
53+
54+
JsonData jsonData = response.body();
55+
56+
popularList = jsonData.getPopular();
57+
58+
loadRecyclerView();
59+
}
60+
61+
@Override
62+
public void onFailure(Call<JsonData> call, Throwable t) {
63+
Toast.makeText(getApplicationContext(), t.toString(), Toast.LENGTH_LONG).show();
64+
65+
}
66+
});
67+
}
68+
69+
private void loadRecyclerView() {
70+
HorizontalAdapter horizontalAdapter = new HorizontalAdapter(getApplicationContext(), popularList);
71+
recyclerView.setAdapter(horizontalAdapter);
72+
recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
73+
}
74+
}

0 commit comments

Comments
 (0)