Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.iml
.gradle
/local.properties
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
.DS_Store
/build
/captures
.externalNativeBuild
Binary file added .idea/caches/build_file_checksums.ser
Binary file not shown.
29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
34 changes: 34 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.android.mygithubclient"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled true
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0'
implementation 'com.squareup.picasso:picasso:2.71828'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.example.android.mygithubclient;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.example.android.mygithubclient", appContext.getPackageName());
}
}
24 changes: 24 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.mygithubclient">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
android:allowBackup="true"
android:icon="@mipmap/octocat"
android:label="@string/app_name"
android:roundIcon="@mipmap/octocat"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.example.android.mygithubclient;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.List;

import static com.example.android.mygithubclient.util.DateUtils.isoDateToNormal;
import static com.example.android.mygithubclient.util.FileUtils.getFileSize;

public class DetailsFragment extends Fragment {

public DetailsFragment() {}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.detail_layout, container, false);
List<TextView> sections = new ArrayList<>();

Repository currentRepository = getArguments().getParcelable("object");

ImageView imageView = rootView.findViewById(R.id.avatarImage);
Picasso.get().load(currentRepository.getAvatar()).into(imageView);

TextView ownerLogin = rootView.findViewById(R.id.ownerLogin);
ownerLogin.setText(currentRepository.getUserLogin());
sections.add(ownerLogin);

TextView repositoryName = rootView.findViewById(R.id.repositoryName);
repositoryName.setText(currentRepository.getName());
sections.add(repositoryName);

TextView starsCount = rootView.findViewById(R.id.starsNumber);
starsCount.setText(currentRepository.getStarsGiven());

TextView watchersCount = rootView.findViewById(R.id.watchersNumber);
watchersCount.setText(currentRepository.getWatchersCount());

TextView forksCount = rootView.findViewById(R.id.forksNumber);
forksCount.setText(currentRepository.getForksCount());

TextView privacy = rootView.findViewById(R.id.typeOfRepo);
privacy.setText(toRepositoryType(currentRepository.isOpenSource()));

TextView language = rootView.findViewById(R.id.programmingDescription);
language.setText(currentRepository.getProgrammingLanguage());
sections.add(language);

TextView issuesCount = rootView.findViewById(R.id.issuesNumber);
issuesCount.setText(currentRepository.getIssuesCount());

TextView branchType = rootView.findViewById(R.id.branchType);
branchType.setText(currentRepository.getBranchesType());
sections.add(branchType);

TextView createdDate = rootView.findViewById(R.id.createDate);
createdDate.setText(isoDateToNormal((currentRepository.getCreatedDate())));

TextView sizeNumber = rootView.findViewById(R.id.sizeNumber);
sizeNumber.setText(getFileSize(currentRepository.getSizeRepo()));

TextView updatedDate = rootView.findViewById(R.id.updatedDate);
updatedDate.setText(isoDateToNormal((currentRepository.getUpdateDate())));

String defaultStatement = getString(R.string.no_info);
for (int i = 0; i < sections.size(); i++) {
TextView currentTextView = sections.get(i);
if(currentTextView.getText().equals(getString(R.string.only_null))){
currentTextView.setText(defaultStatement);
}
}
return rootView;
}

private String toRepositoryType(boolean isOpenSource){
return isOpenSource ? getString(R.string.privates) : getString(R.string.publics);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.example.android.mygithubclient;

import org.json.JSONException;
import org.json.JSONObject;

public class JsonRepositoryParser {

public JsonRepositoryParser(){}

public static Repository parseRepository(JSONObject jsonRepository) throws JSONException {
String fullName = jsonRepository.getString("full_name");
String starsGiven = jsonRepository.getString("stargazers_count");
String watchersCount = jsonRepository.getString("watchers_count");
String forksCount = jsonRepository.getString("forks_count");
boolean openSource = jsonRepository.getBoolean("private");
String programmingLanguage = jsonRepository.getString("language");
String issuesCount = jsonRepository.getString("open_issues_count");
String branchesType = jsonRepository.getString("default_branch");
String createdDate = jsonRepository.getString("created_at");
String updatedDate = jsonRepository.getString("updated_at");
long sizeRepo = jsonRepository.getLong("size");
String name = jsonRepository.getString("name");
JSONObject owner = jsonRepository.getJSONObject("owner");
String avatar = owner.getString("avatar_url");
String userLogin = owner.getString("login");
return new RepositoryBuilder().setFullName(fullName).setStarsGiven(starsGiven)
.setAvatar(avatar).setUserLogin(userLogin).setWatchersCount(watchersCount)
.setForksCount(forksCount).setOpenSource(openSource)
.setProgrammingLanguage(programmingLanguage).setIssuesCount(issuesCount)
.setBranchesType(branchesType).setCreatedDate(createdDate)
.setUpdatedDate(updatedDate).setSizeRepo(sizeRepo).setName(name)
.createRepository();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.android.mygithubclient;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

public static final String LOG = MainActivity.class.getName();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SearchFragment fragment = new SearchFragment();
android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.view_pager,fragment).commit();
}
}
Loading