Skip to content

Commit

Permalink
code repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirtyDegreesRay committed Jul 25, 2017
1 parent 5002aaf commit 77c8deb
Show file tree
Hide file tree
Showing 58 changed files with 420 additions and 43 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OpenHub
An android client for GitHub.
The best android client of GitHub.

![OpenHub](https://github.com/ThirtyDegreesRay/OpenHub/raw/master/art/openhub.png)

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
</activity>
<activity
android:name=".ui.activity.RepositoryActivity"
android:label="@string/title_activity_repository"
android:theme="@style/AppTheme.NoActionBar">
</activity>
</application>

</manifest>
8 changes: 8 additions & 0 deletions app/src/main/java/com/thirtydegreesray/openhub/AppApplication.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.thirtydegreesray.openhub;

import android.app.Application;
import android.util.Log;

import com.orhanobut.logger.LogLevel;
import com.orhanobut.logger.Logger;
Expand All @@ -42,11 +43,18 @@ public void onCreate() {
super.onCreate();
application = this;
//init application
long startTime = System.currentTimeMillis();
Log.i(TAG, "startTime:" + startTime);
mAppComponent = DaggerAppComponent.builder()
.appModule(new AppModule(this))
.build();
Log.i(TAG, "dagger ok:" + (System.currentTimeMillis() - startTime));
startTime = System.currentTimeMillis();
initLogger();
Log.i(TAG, "logger ok:" + (System.currentTimeMillis() - startTime));
startTime = System.currentTimeMillis();
NetHelper.getInstance().init(this);
Log.i(TAG, "net ok:" + (System.currentTimeMillis() - startTime));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class AppConfig {

public final static String GITHUB_API_BASE_URL = "https://api.github.com/";

public final static int HTTP_TIME_OUT = 8 * 1000;
public final static int HTTP_TIME_OUT = 16 * 1000;

public final static int MAX_CACHE_SIZE = 8 * 1024 * 1024;

Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ public void onError(Throwable error) {
@Override
public void onSuccess(HttpResponse<ArrayList<Repository>> response) {
mView.showRepositories(response.body());
if(isLastResponse(response)){
mView.hideLoadingView();
}
mView.hideLoadingView();
// if(isLastResponse(response)){
// mView.hideLoadingView();
// }
}
};

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2017 ThirtyDegressRay
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.thirtydegreesray.openhub.ui.activity;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.thirtydegreesray.openhub.R;

public class RepositoryActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_repository);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
}
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {
holder.tvOwnerName.setText(repository.getOwner().getLogin());
Picasso.with(mContext)
.load(repository.getOwner().getAvatarUrl())
.placeholder(R.mipmap.logo)
.into(holder.ivUserAvatar);

}
Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.thirtydegreesray.openhub.ui.fragment;

import android.content.Intent;
import android.os.Bundle;

import com.thirtydegreesray.openhub.R;
Expand All @@ -25,6 +26,7 @@
import com.thirtydegreesray.openhub.mvp.contract.IRepositoriesContract;
import com.thirtydegreesray.openhub.mvp.model.Repository;
import com.thirtydegreesray.openhub.mvp.presenter.RepositoriesPresenter;
import com.thirtydegreesray.openhub.ui.activity.RepositoryActivity;
import com.thirtydegreesray.openhub.ui.adapter.RepositoriesAdapter;
import com.thirtydegreesray.openhub.ui.fragment.base.ListFragment;

Expand Down Expand Up @@ -93,7 +95,7 @@ protected void setupFragmentComponent(AppComponent appComponent) {
}

@Override
protected void initFragment(Bundle savedInstanceState) {
protected void initFragment(Bundle savedInstanceState){
super.initFragment(savedInstanceState);
mPresenter.loadRepositories(repositoriesType, language, false);
}
Expand All @@ -108,4 +110,9 @@ protected String getEmptyTip() {
return getString(R.string.no_repositories);
}

@Override
public void onItemClick(int position) {
super.onItemClick(position);
startActivity(new Intent(getActivity(), RepositoryActivity.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public abstract class ListFragment <P extends BasePresenter, A extends BaseAdapt
@Override
protected void initFragment(Bundle savedInstanceState) {
refreshLayout.setOnRefreshListener(this);
refreshLayout.setColorSchemeResources(R.color.colorPrimary);

recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
adapter.setOnItemLongClickListener(this);
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:width="16dp"
android:height="16dp"
android:viewportWidth="16.0"
android:viewportHeight="16.0">
<path
android:fillColor="@android:color/darker_gray"
android:fillColor="#FF000000"
android:pathData="M8 1a1.993 1.993 0 0 0-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 0 0 2 1a1.993 1.993 0 0 0-1 3.72V6.5l3 3v1.78A1.993 1.993 0 0 0 5 15a1.993 1.993 0 0 0 1-3.72V9.5l3-3V4.72A1.993 1.993 0 0 0 8 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"/>
</vector>
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:width="16dp"
android:height="16dp"
android:viewportWidth="16.0"
android:viewportHeight="16.0">
<path
android:fillColor="#FF000000"
android:pathData="M18,2H6c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V4c0,-1.1 -0.9,-2 -2,-2zM6,4h5v8l-2.5,-1.5L6,12V4z"/>
android:pathData="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"/>
</vector>
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:width="16dp"
android:height="16dp"
android:viewportWidth="16.0"
android:viewportHeight="16.0">
<path
android:fillColor="@android:color/darker_gray"
android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/>
android:fillColor="#FF000000"
android:pathData="M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z"/>
</vector>
82 changes: 82 additions & 0 deletions app/src/main/res/layout/activity_repository.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2017 ThirtyDegressRay
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<android.support.design.widget.CoordinatorLayout
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:fitsSystemWindows="true"
tools:context="com.thirtydegreesray.openhub.ui.activity.RepositoryActivity">

<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:expandedTitleMarginStart="12dp"
app:expandedTitleMarginBottom="22dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="The best android client of GitHub, faster, faster, faster, faster."
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp"
android:layout_marginEnd="90dp"
android:maxLines="3"/>

<com.makeramen.roundedimageview.RoundedImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@mipmap/logo"
android:layout_gravity="center_vertical|end"
android:layout_margin="6dp"
app:riv_oval="true"/>

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay"/>

</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:layout_gravity="bottom|end"
app:layout_anchorGravity="bottom|end"
app:srcCompat="@android:drawable/ic_dialog_email"/>

<include layout="@layout/content_repository"/>

</android.support.design.widget.CoordinatorLayout>
Loading

0 comments on commit 77c8deb

Please sign in to comment.