Commit 01796b31 authored by isnirp's avatar isnirp

demo

parent b5b4b5c7
......@@ -23,7 +23,7 @@
<PersistentState>
<option name="values">
<map>
<entry key="url" value="jar:file:/C:/Program%20Files/Android/Android%20Studio/plugins/android/lib/android.jar!/images/material_design_icons/action/ic_event_black_24dp.xml" />
<entry key="url" value="jar:file:/C:/Program%20Files/Android/Android%20Studio/plugins/android/lib/android.jar!/images/material_design_icons/content/ic_add_black_24dp.xml" />
</map>
</option>
</PersistentState>
......@@ -33,7 +33,7 @@
</option>
<option name="values">
<map>
<entry key="outputName" value="ic_action_cal" />
<entry key="outputName" value="ic_action_add" />
</map>
</option>
</PersistentState>
......
......@@ -25,7 +25,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
......@@ -38,6 +38,8 @@ dependencies {
implementation "com.android.support:design:$rootProject.ext.androidSupportVersion"
implementation "com.android.support:support-v4:$rootProject.ext.androidSupportVersion"
implementation "com.android.support:appcompat-v7:$rootProject.ext.androidSupportVersion"
//firebase
implementation 'com.google.firebase:firebase-database:16.0.5'
//picasso
implementation "com.squareup.picasso:picasso:$rootProject.ext.picassoVersion"
......@@ -59,3 +61,5 @@ dependencies {
implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
compileOnly 'javax.annotation:jsr250-api:1.0'
}
//Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
\ No newline at end of file
{
"project_info": {
"project_number": "458556553652",
"firebase_url": "https://qifirebaseproject-c45d8.firebaseio.com",
"project_id": "qifirebaseproject-c45d8",
"storage_bucket": "qifirebaseproject-c45d8.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:458556553652:android:4c81c9a5771e71d3",
"android_client_info": {
"package_name": "com.flimbis.qi"
}
},
"oauth_client": [
{
"client_id": "458556553652-noc0uv1kfu3795vrmbbt2ha16rhs0i7t.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.flimbis.qi",
"certificate_hash": "fc0e17a2635c30ed4c91c7785e99483a537a5320"
}
},
{
"client_id": "458556553652-hjgg5krvrt34rtickhvk5d486julk5ka.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyCtc-hEuCiX6B-e9rLBQ6LMyWxM3cAIhqk"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 2,
"other_platform_oauth_client": [
{
"client_id": "458556553652-hjgg5krvrt34rtickhvk5d486julk5ka.apps.googleusercontent.com",
"client_type": 3
}
]
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
......@@ -3,6 +3,7 @@
package="com.flimbis.qi">
<application
android:name=".QiApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
......@@ -16,9 +17,11 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.profile.ProfileActivity" />
<activity android:name=".ui.events.EventsActivity" />
<activity android:name=".ui.courses.CourseActivity"></activity>
<activity android:name=".ui.profile.ProfileActivity"
android:parentActivityName=".MainActivity"/>
<activity android:name=".ui.events.EventsActivity"
android:parentActivityName=".MainActivity"/>
<activity android:name=".ui.courses.detail.CourseActivity"></activity>
</application>
</manifest>
\ No newline at end of file
......@@ -3,23 +3,38 @@ package com.flimbis.qi;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.flimbis.qi.adapter.AgendaStreakAdapter;
import com.flimbis.qi.adapter.HomeAdapter;
import com.flimbis.qi.di.component.AppComponent;
import com.flimbis.qi.model.EventModel;
import com.flimbis.qi.ui.events.EventsActivity;
import com.flimbis.qi.ui.home.MainPresenter;
import com.flimbis.qi.ui.home.ViewContract;
import com.flimbis.qi.ui.profile.ProfileActivity;
import java.util.List;
import javax.inject.Inject;
import de.hdodenhof.circleimageview.CircleImageView;
public class MainActivity extends AppCompatActivity implements ViewContract.View {
private Toolbar toolbar;
private CircleImageView profileImage;
private RecyclerView recyclerView;
private RecyclerView recyAgenda;
private HomeAdapter adapter;
private AgendaStreakAdapter agendaAdapter;
@Inject
MainPresenter presenter;
@Override
......@@ -31,17 +46,23 @@ public class MainActivity extends AppCompatActivity implements ViewContract.View
initViews();
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("");
getApplicationComponent().inject(this);
presenter.setView(this);
presenter.load();
}
@Override
protected void onResume() {
super.onResume();
/* profileImage.setOnClickListener(new View.OnClickListener() {
profileImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
presenter.navigateToProfile();
presenter.navigateToProfile();
}
});*/
});
}
@Override
......@@ -57,23 +78,21 @@ public class MainActivity extends AppCompatActivity implements ViewContract.View
Intent intent = new Intent(this, EventsActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.slide_from_right /*enterAnimationId*/, R.anim.slide_to_left/*exitAnimationId*/);
// presenter.navigateToEvents();
// presenter.navigateToEvents();
return true;
/* case android.R.id.home:
presenter.navigateToProfile();
return true;*/
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void showDashboard() {
}
@Override
public void showProfile() {
Intent intent = new Intent(this, ProfileActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.slide_from_right /*enterAnimationId*/, R.anim.slide_to_left/*exitAnimationId*/);
overridePendingTransition(R.anim.slide_from_left /*enterAnimationId*/, R.anim.slide_to_right/*exitAnimationId*/);
}
@Override
......@@ -83,6 +102,24 @@ public class MainActivity extends AppCompatActivity implements ViewContract.View
overridePendingTransition(R.anim.slide_from_right /*enterAnimationId*/, R.anim.slide_to_left/*exitAnimationId*/);
}
@Override
public void showDashboard(List<EventModel> eventModelList) {
agendaAdapter = new AgendaStreakAdapter(this, eventModelList);
recyAgenda.setAdapter(agendaAdapter);
}
@Override
public void showRecentEvents(List<EventModel> eventModelList) {
for(EventModel model: eventModelList){
if(model.getAlias() == "mobserv"){
Toast.makeText(this,model.getName(), Toast.LENGTH_SHORT).show();
}
Log.i("MainAc",""+model.getAlias());
}
adapter = new HomeAdapter(this, eventModelList);
recyclerView.setAdapter(adapter);
}
@Override
public boolean isLogin() {
return false;
......@@ -95,6 +132,7 @@ public class MainActivity extends AppCompatActivity implements ViewContract.View
@Override
public void showMessage(String msg, String type) {
Toast.makeText(this,msg, Toast.LENGTH_SHORT).show();
}
......@@ -102,5 +140,16 @@ public class MainActivity extends AppCompatActivity implements ViewContract.View
toolbar = (Toolbar) findViewById(R.id.toolbar);
profileImage = findViewById(R.id.img_prof);
recyclerView = findViewById(R.id.recy_main);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(linearLayoutManager);
recyAgenda = findViewById(R.id.recy_agenda);
LinearLayoutManager horLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
recyAgenda.setLayoutManager(horLayoutManager);
}
private AppComponent getApplicationComponent() {
return QiApplication.getInstance().getAppComponent();
}
}
package com.flimbis.qi;
import android.app.Application;
import com.flimbis.qi.di.component.AppComponent;
import com.flimbis.qi.di.component.DaggerAppComponent;
import com.flimbis.qi.di.module.ApiModule;
import com.flimbis.qi.di.module.AppModule;
public class QiApplication extends Application {
private static QiApplication INSTANCE;
private static AppComponent appComponent;
public static QiApplication getInstance() {
INSTANCE = new QiApplication();
return INSTANCE;
}
@Override
public void onCreate() {
super.onCreate();
getAppComponent();
}
public AppComponent getAppComponent() {
if (appComponent == null) {
appComponent = DaggerAppComponent.builder()
.appModule(new AppModule(this))
.apiModule(new ApiModule("https://qifirebaseproject-c45d8.firebaseio.com/"))
.build();
}
return appComponent;
}
}
\ No newline at end of file
......@@ -9,14 +9,22 @@ import android.view.ViewGroup;
import android.widget.TextView;
import com.flimbis.qi.R;
import com.flimbis.qi.model.EventModel;
import java.util.ArrayList;
import java.util.List;
import de.hdodenhof.circleimageview.CircleImageView;
public class AgendaStreakAdapter extends RecyclerView.Adapter<AgendaStreakAdapter.ViewHolder>{
private Context context;
private List<EventModel> items;
private String[] day = {"s","m","t","w","t","f","s"};
private List<String> days = new ArrayList<>();
public AgendaStreakAdapter(Context context) {
public AgendaStreakAdapter(Context context, List<EventModel> items) {
this.context = context;
this.items = items;
}
@NonNull
......@@ -28,12 +36,12 @@ public class AgendaStreakAdapter extends RecyclerView.Adapter<AgendaStreakAdapte
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
EventModel model = items.get(position);
}
@Override
public int getItemCount() {
return 0;
return items.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
......
package com.flimbis.qi.adapter;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.flimbis.qi.R;
import com.flimbis.qi.model.CourseModel;
import java.util.List;
import de.hdodenhof.circleimageview.CircleImageView;
public class CourseAdapter extends RecyclerView.Adapter<CourseAdapter.ViewHolder> {
private Context context;
private List<CourseModel> items;
public CourseAdapter(Context context, List<CourseModel> items) {
this.context = context;
this.items = items;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.items_general, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
CourseModel course = items.get(position);
holder.title.setText(course.getAlias());
}
@Override
public int getItemCount() {
return items.size();
}
class ViewHolder extends RecyclerView.ViewHolder {
TextView title;
CircleImageView img;
public ViewHolder(View itemView) {
super(itemView);
title = itemView.findViewById(R.id.txt_gen_title);
img = itemView.findViewById(R.id.img_gen_icon);
}
}
}
......@@ -2,48 +2,132 @@ package com.flimbis.qi.adapter;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.flimbis.qi.R;
import com.flimbis.qi.model.EventModel;
public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.ViewHolder>{
import java.util.List;
public class HomeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
private Context context;
private final int AGENDA = 0;
private List<EventModel> items;
private final int AGENDA = 0;//all
private final int COURSE = 1;
private final int TODO_TASK = 2;
public HomeAdapter(Context context) {
public HomeAdapter(Context context, List<EventModel> items) {
this.context = context;
this.items = items;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return null;
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
RecyclerView.ViewHolder viewHolder;
LayoutInflater inflater = LayoutInflater.from(context);
switch (viewType) {
case COURSE:
View course_view = inflater.inflate(R.layout.items_main, parent, false);
viewHolder = new ViewHolder(course_view);
break;
case TODO_TASK:
View todo_view = inflater.inflate(R.layout.items_main_todo, parent, false);
viewHolder = new TodoViewHolder(todo_view);
break;
default:
View def_view = inflater.inflate(R.layout.items_main, parent, false);
viewHolder = new ViewHolder(def_view);
break;
}
return viewHolder;
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
switch (holder.getItemViewType()) {
case COURSE:
ViewHolder courseViewHolder = (ViewHolder) holder;
bindCourseViewHolder(courseViewHolder, position);
break;
case TODO_TASK:
TodoViewHolder todoViewHolder = (TodoViewHolder) holder;
bindTodoViewHolder(todoViewHolder, position);
break;
default:
break;
}
}
private void bindTodoViewHolder(TodoViewHolder todoViewHolder, int position) {
EventModel event = items.get(position);
todoViewHolder.type.setText("GROUP(mobserv)");
todoViewHolder.title.setText(event.getAlias());
todoViewHolder.desc.setText(event.getDescription());
}
private void bindCourseViewHolder(ViewHolder courseViewHolder, int position) {
EventModel event = items.get(position);
courseViewHolder.type.setText("CLASS"+"("+event.getVenue().get(0)+")");
courseViewHolder.title.setText(event.getAlias());
courseViewHolder.date.setText("starts~"+event.getStart());//start and end
}
@Override
public int getItemCount() {
return 0;
return items.size();
}
@Override
public int getItemViewType(int position) {
//class
if (items.get(position).getType()== 0) {
return COURSE;
} else {
return TODO_TASK;
}
}
public class ViewHolder extends RecyclerView.ViewHolder{
private TextView type;
private TextView title;
private TextView date;
private CardView card;
public ViewHolder(View itemView) {
super(itemView);
card = itemView.findViewById(R.id.card_main);
type = itemView.findViewById(R.id.txt_main_type);
title = itemView.findViewById(R.id.txt_main_title);
date = itemView.findViewById(R.id.txt_main_date);
}
}
public class TodoViewHolder extends RecyclerView.ViewHolder{
private TextView type;
private TextView title;
private TextView desc;
private CardView todoCard;
public TodoViewHolder(View itemView) {
super(itemView);
todoCard = itemView.findViewById(R.id.card_main_todo);
type = itemView.findViewById(R.id.txt_main_td_type);
title = itemView.findViewById(R.id.txt_main_td_title);
desc = itemView.findViewById(R.id.txt_main_td_desc);
}
}
}
package com.flimbis.qi.di.component;
import com.flimbis.qi.MainActivity;
import com.flimbis.qi.di.module.ApiModule;
import com.flimbis.qi.di.module.AppModule;
import com.flimbis.qi.di.module.EventsDatasourceModule;
import com.flimbis.qi.di.module.HomeModule;
import com.flimbis.qi.di.module.UsersDataSourceModule;
import com.flimbis.qi.di.scope.ApplicationScope;
import com.flimbis.qi_core.repository.EventRepository;
import com.flimbis.qi_core.repository.UserRepository;
import com.flimbis.qi_data.datasource.remote.ApiService;
import com.flimbis.qi_data.datasource.remote.FireDatabaseManager;
import dagger.Component;
import io.reactivex.Scheduler;
@ApplicationScope
@Component(modules = {AppModule.class, ApiModule.class,HomeModule.class,EventsDatasourceModule.class, UsersDataSourceModule.class})
public interface AppComponent {
void inject(MainActivity mainActivity);
//expose
Scheduler getUiThreadScheduler();
//FireDatabaseManager getFireDatabaseManager();
ApiService getApiService();
EventRepository getEventRepository();
UserRepository getUserRepository();
}
package com.flimbis.qi.di.component;
import com.flimbis.qi.di.module.CourseModule;
import com.flimbis.qi.di.scope.CustomScope;
import com.flimbis.qi.ui.courses.CourseFragment;
import dagger.Component;
@CustomScope
@Component(modules = CourseModule.class, dependencies = AppComponent.class)
public interface CourseComponent {
void inject(CourseFragment courseFragment);
}
package com.flimbis.qi.di.component;
import com.flimbis.qi.di.module.EventsModule;
import com.flimbis.qi.di.scope.CustomScope;
import com.flimbis.qi.ui.events.EventsActivity;
import dagger.Component;
@CustomScope
@Component(modules = EventsModule.class, dependencies = AppComponent.class)
public interface EventsComponent {
void inject(EventsActivity eventsActivity);
//expose
}
package com.flimbis.qi.di.module;
import com.flimbis.qi.di.scope.ApplicationScope;
import com.flimbis.qi_data.datasource.remote.ApiService;
import com.google.gson.Gson;
import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import dagger.Module;
import dagger.Provides;
import retrofit2.CallAdapter;
import retrofit2.Converter;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
@Module
public class ApiModule {
private String baseUrl;
public ApiModule(String baseUrl) {
this.baseUrl = baseUrl;
}
@Provides
@ApplicationScope
ApiService provideApiService(Retrofit retrofit) {
return retrofit.create(ApiService.class);
}
@Provides
@ApplicationScope
Retrofit provideRetrofit(String baseUrl, Converter.Factory converterFactory, CallAdapter.Factory callAdapter) {
return new Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(converterFactory)
.addCallAdapterFactory(callAdapter)
.build();
}
@Provides
@ApplicationScope
String provideBaseUrl() {
return baseUrl;
}
@Provides
@ApplicationScope
public Converter.Factory provideGsonConverterFactory(Gson gson) {
return GsonConverterFactory.create(gson);
}
@Provides
@ApplicationScope
public CallAdapter.Factory provideCallAdapterFactory() {
return RxJava2CallAdapterFactory.create();
}
@Provides
@ApplicationScope
public Gson provideGson() {
return new Gson();
}
}
package com.flimbis.qi.di.module;
import android.content.Context;
import com.flimbis.qi.QiApplication;
import com.flimbis.qi.di.qualifier.ApplicationContext;
import com.flimbis.qi.di.scope.ApplicationScope;
import com.flimbis.qi_data.datasource.remote.FireDatabaseManager;
import com.google.firebase.database.FirebaseDatabase;
import dagger.Module;
import dagger.Provides;