Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadmssm committed Jan 11, 2019
1 parent 1ab0947 commit 08460f6
Show file tree
Hide file tree
Showing 69 changed files with 1,905 additions and 0 deletions.
10 changes: 10 additions & 0 deletions AndroidBase/.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 AndroidBase/.idea/caches/build_file_checksums.ser
Binary file not shown.
29 changes: 29 additions & 0 deletions AndroidBase/.idea/codeStyles/Project.xml

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

7 changes: 7 additions & 0 deletions AndroidBase/.idea/dictionaries/ams.xml

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

20 changes: 20 additions & 0 deletions AndroidBase/.idea/gradle.xml

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

34 changes: 34 additions & 0 deletions AndroidBase/.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 AndroidBase/.idea/runConfigurations.xml

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

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

android {
compileSdkVersion 28



defaultConfig {
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

sourceSets { main { res.srcDirs = ['src/main/res', 'src/main/res/layout'] } }
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.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.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'android.arch.persistence.room:runtime:1.1.1'
annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation "com.github.skydoves:preferenceroom:1.1.3"
annotationProcessor "com.github.skydoves:preferenceroom-processor:1.1.3"
implementation 'frankiesardo:icepick:3.2.0'
compileOnly 'frankiesardo:icepick-processor:3.2.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
implementation 'it.sephiroth.android.library.imagezoom:imagezoom:+'
implementation 'org.parceler:parceler-api:1.1.12'
annotationProcessor 'org.parceler:parceler:1.1.12'
}
21 changes: 21 additions & 0 deletions AndroidBase/androidBase/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 ams.android_base;

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("ams.android_base.test", appContext.getPackageName());
}
}
24 changes: 24 additions & 0 deletions AndroidBase/androidBase/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="ams.android_base">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:label="@string/app_name">
<meta-data
android:name="android.support.VERSION"
android:value="28.0.0"
tools:replace="android:value" />

<activity android:name=".ZoomImageActivity">
<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,44 @@
package ams.android_base;


import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import retrofit2.Converter;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;

@SuppressWarnings({"WeakerAccess", "unused"})
public abstract class BaseAPIsConnector {

private static Retrofit retrofit;

protected OkHttpClient.Builder getOkHttpBuilder() {
int timeOut = 200;
return new OkHttpClient.Builder()
.connectTimeout(timeOut, TimeUnit.SECONDS)
.writeTimeout(timeOut, TimeUnit.SECONDS)
.readTimeout(timeOut, TimeUnit.SECONDS);
}

protected Retrofit.Builder getRetrofitBuilder() {
return new Retrofit.Builder()
.baseUrl(getBaseURL())
.addConverterFactory(getConverterFactory())
.client(getOkHttpBuilder().build())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create());
}

protected final void buildRetrofit () { if (retrofit == null) retrofit = getRetrofitBuilder().build(); }

protected Retrofit getRetrofit () { return retrofit; }

protected <APIsInterface> APIsInterface getRetrofitClient(Class<APIsInterface> restAPIsInterface) {
buildRetrofit();
return retrofit.create(restAPIsInterface);
}

protected abstract String getBaseURL ();
protected abstract Converter.Factory getConverterFactory ();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package ams.android_base;

import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.WindowManager;

import it.sephiroth.android.library.imagezoom.ImageViewTouch;

public abstract class ZoomImageActivity extends AppCompatActivity {

protected ImageViewTouch imageView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initView();
renderImageView();
}

private void initView() {
setContentView(R.layout.activity_zoom_image);
if(getSupportActionBar() != null) getSupportActionBar().hide();
// Remove activity title
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
//noinspection deprecation,RedundantCast
imageView = (ImageViewTouch) findViewById(R.id.imageView);
}

protected abstract void renderImageView ();

@Override
public void onBackPressed() {
super.onBackPressed();
this.finish();
}


// This is how to send image to view/zoom image page
// Bitmap will be cached for 10 seconds only
// public void sendImageToViewPage (Bitmap bitmap) {
// new CacheManger(this).cacheBitmapTemporary(GlobalKeys.TEMP_BITMAP, bitmap, 10);
// Intent intent = new Intent(this, ZoomImageActivity.class);
// startActivity(intent);
// }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package ams.android_base.baseClasses;

@SuppressWarnings("WeakerAccess")
public class BasePage<T> {

private int itemsCount;
private int itemsPerPage = 20;
private int pageNumber = 1;

public void setItemsCount(int itemsCount) { this.itemsCount = itemsCount; }

public int getItemsPerPage() { return itemsPerPage; }

public int getPageNumber() { return pageNumber; }


// Helper methods
public void resetPageCount () { this.pageNumber = 1; }

public void incrementPageNumber () { this.pageNumber ++; }

public int getTotalNumberOfPages() {
float tempItemsCount = itemsCount;
float tempItemsPerPage = itemsPerPage;
return (int) (Math.ceil(tempItemsCount/tempItemsPerPage));
}

public boolean hasNext() { return pageNumber <= getTotalNumberOfPages(); }

public void resetPage () { resetPageCount(); }

}
Loading

0 comments on commit 08460f6

Please sign in to comment.